gpt4 book ai didi

c# - 数据集值

转载 作者:行者123 更新时间:2023-11-30 18:30:25 32 4
gpt4 key购买 nike

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

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/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com