1
從數據庫中,我返回一個包含一個或多個表的數據集。 這些表格將具有相同數量的列。在多個數據中搜索特定字符串的有效方法表
我想檢查是否有多個表中存在與第一個表的特定字符串共同的行。
for(int i=0; i<ds.Table[0].Rows.Count;i++)
{
var firstTableRowValue = ds.Table[0].Rows[i][0].ToString();
//Check firstTableRowValue exists in other dataTables if exists retrive other column values and delete that row from the table.
}
會是怎樣做的在C#
您需要創建一個unionDataTable,它將包含除第一個表之外的所有表,如下所示:http://forums.asp.net/t/1469565.aspx?How+to+combine+all+tables+in+a + data + set + into + one + table + or + into + one + DataSet +然後使用linq執行單個搜索。 –
我認爲我的要求與他的要求不同。我必須再添加兩列以在另一個表中進行特定。我的意思是 我在表格[1]中找到了我搜索到的字符串可以說 然後 新表應該有 SearchStringColumn | Table0_Col1 | Table0_Col2 | Table1_Col1 | Table1_Col2 再次如果在表[2]中找到,則再添加兩個列Table2_Col1和Table2_Col2,並且進程繼續並繼續 –