关于DataTable和DataSet的帮助 [英] Help Regarding DataTable and DataSet
问题描述
我有两个DataTables
一种是来自本地数据库(由存储过程填充),可以说datatable1
第二个来自远程(即来自服务器的数据库),可以说datatable2
两者具有相同的表和记录,但是同一列(称为可访问)记录的区别在于该列的某些记录具有不同的值
我想检查一下,如果datatable2accessible是NO,那么更新datatable1可以访问NO
我已经完成以下代码:
I have two DataTables
One is from local database(Populated with Stored Procedure) let say datatable1
Second one is coming from Remotely(ie From a server''s database) let say datatable2
Both have same table and records,but difference is of one column (named Accessible) records is that some records of this column have different values
I want to apply a check that if datatable2 accessible is NO then update datatable1 accessible to NO
I have done folowing code:
foreach(DataTableRows dr in datatable2.Rows)
{
if(dr["Accessible"].ToString() == "NO")
{
//Here i want to apply code
}
}
How can i update dynamically datatable1?
推荐答案
首先,您必须在datatable1中找到匹配的行.根据您提供的信息,无法说出该如何做,但是很可能您在可以使用的两个数据表上都有一个键.
然后,您可以使用例如选择 [
First you have to find the matching row in datatable1. Based on the info you provided it''s impossible to say how to do that but most likely you have a key on both data tables which you could use.
You could then use for example the Select[^] method to fetch the matching row from datatable1 and compare the values.
这篇关于关于DataTable和DataSet的帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!