c# - 数据集值

标签 c# asp.net

我正在接收数据集中的一些数据。我可以比较数据集表中的值吗

DataSet ds = new DataSet();
ds = db.ExecuteDataSet("select *  from tblSeatAssignmentDetails where SeatAssignmentID=" + SeatAssignmentId);
if (ds.Tables[0].Rows.Count < ProcessID.Count())
{
    for (int j = 0; j < ProcessID.Count(); j++)
    {
        DBAccess db1 = new DBAccess();
        DataSet objds = new DataSet();
        objds = db1.ExecuteDataSet("Select * from tblSeatAssignmentDetails
                                        where ProcessID=" + ProcessID[j] + "");
        if (objds.Tables[0].Rows.Count != 0)
        //here in this place i need to compare with the columns of the objds dataset column ie..processID)
        {
            string DeactivateDateTime = "null";
            i = db.ExecuteNonQuery("Insert INTO tblSeatAssignmentDetails Values(" + SeatAssignmentId + "," + ProcessID[j] + ",'" + DateTime.Now + "','1'," + DeactivateDateTime + ")");
        }
    }
}

//在这个地方,我需要与 objds 数据集列 ie..processID 的列进行比较。

有没有可能得到结果。

最佳答案

这是你想要的吗?

if (objds.Tables[0].Rows.Count > 0)
    //here in this place i need to compare with the columns of the objds dataset column ie..processID)
    {
        string columnValueFromFirstResultSet = ds.Tables[0].Rows[j]["COLUMNNAME"].ToString();

        for (int i = 0; i < objds.Tables[0].Rows.Count - 1; i++)
        {
            string columnValueOfFirstRow = objds.Tables[0].Rows[i]["COLUMNNAME"].ToString();

            if (columnValueFromFirstResultSet != columnValueOfFirstRow)
            {
                //Do something
            }
        }

        string DeactivateDateTime = "null";
        i = db.ExecuteNonQuery("Insert INTO tblSeatAssignmentDetails Values(" + SeatAssignmentId + "," + ProcessID[j] + ",'" + DateTime.Now + "','1'," + DeactivateDateTime + ")");
    }

关于c# - 数据集值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21553985/

相关文章:

c# - Razor "if"语句中的 HtmlHelper

c# - 使用手机时需要从网站推荐手机应用商店链接

c# - 为什么SPAN的值没有更新

javascript - RadioButtonList 在 javascript 中选择的值

asp.net - FileNotFoundException : Could not load file or assembly 'System.Net.Http.WebRequest'

c# - 我使用rigidbody2D.velocity.y时出现语法错误

javascript - 如何从 Javascript 调用 C# 函数

c# - 使用 C# 删除大量(>100K)文件,同时保持 Web 应用程序的性能?

asp.net - 上下文菜单没有 "Add Scaffolding"和 "Add Controller"选项

android - 如何使用Mvc JsonResult返回纯html