数据集值

时间:2014-02-04 13:34:18

标签: 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数据集列的列进行比较,即..processID)。

是否有可能获得结果。

1 个答案:

答案 0 :(得分:0)

这是你想要的吗?

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 + ")");
    }