我正在向 DataSet 添加两个表,我想检查它们是否相等。
我试过的代码是:
SqlDataAdapter mydat = new SqlDataAdapter("Select Device_Profile_Param+'='+Device_Profile_Default_Value AS SettingsCheck From Device_Profile_Master Where Device_Profile_Name = '" + Label5.Text + "'", con);
DataTable dt = new DataTable();
mydat.Fill(dt);
DataSet dset = new DataSet();
dset.Tables.Add(dt);
SqlDataAdapter mydata = new SqlDataAdapter("Select Device_Profile_Param+'='+Device_Profile_Default_Value AS Settings From Device_Profile_Master Where Device_Profile_Name = '" + For_Profile_Num.Items[i] + "'", con);
DataTable dt2 = new DataTable();
mydata.Fill(dt2);
dset.Tables.Add(dt2);
var hashSet1 = new HashSet<string>(dset.Tables[0].Rows.Cast<ListItem>().Select(x => x.Value));
var hashSet2 = new HashSet<string>(dset.Tables[1].Rows.Cast<ListItem>().Select(x => x.Value));
var result = hashSet1.SetEquals(hashSet2);
if (result == true)
{
found = 1;
}
我收到一个错误DataSet cannot be cast as ListItem。请帮忙。