Dataset Values

I get some data in a dataset. Can compare values ​​in dataset table

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

// here in this place I need to compare with the columns of the data set column objds ie..processID).

Is it possible to get a result.

+3
source share
1 answer

Is this what you want?

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

All Articles