我在DataSet中有一个表,我想使用唯一键在此表中搜索一行.
我的问题是:有没有任何方法可以让我在不使用循环的情况下找到这一行?
这是我使用forech循环编写的代码:
foreach (var myRow in myClass.ds.Tables["Editeur"].AsEnumerable())
{
if (newKeyWordAEditeurName == myRow[1] as String)
id_Editeur_Editeur = (int)myRow[0];
}
Run Code Online (Sandbox Code Playgroud)
Dav*_*d W 13
当然.您有一个DataTable的Select方法.从您的DataSet中转换表,并使用Select来阻止它.
void Demo(DataSet ds)
{
DataTable dt = ds.Tables[0]; // refer to your table of interest within the DataSet
dt.Select("Field = 1"); // replace with your criteria as appropriate
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
33172 次 |
| 最近记录: |