PDA

View Full Version : جستجو در DataSet



shima alavi
شنبه 23 مهر 1390, 23:37 عصر
سلام و خسته نباشد زیاد بر شما استادان گرامی.
میخواستم ببینم چطور میشه در یه Dataset یه item خاص رو جستجو کرد؟

sanay_esh
شنبه 23 مهر 1390, 23:50 عصر
سلام
string s = "primaryKeyValue";
DataRow foundRow = dataSet1.Tables["AnyTable"].Rows.Find(s);

if (foundRow != null)
{
MessageBox.Show(foundRow[1].ToString());
}
else
{
MessageBox.Show("A row with the primary key of " + s + " could not be found");
}

Dim s As String = "primaryKeyValue"
Dim foundRow As DataRow = DataSet1.Tables("AnyTable").Rows.Find(s)

If foundRow IsNot Nothing Then
MsgBox(foundRow(1).ToString())
Else
MsgBox("A row with the primary key of " & s & " could not be found")
End If