i have one column in my database by name PNUMSET (Primary Key) contains unique data.(approx 1L rows)
and in application i have one datatable with one column name NEWPNUM which contains data.
i want to check that no value is matching between existing database and current datatable values..
Note:- no of rows may or may not be same in database and datatable.
so far i tried…..
String query = "Select PNUMSET FROM DUMMYTABLE";
MySqlDataAdapter msda = new MySqlDataAdapter(query, connection);
msda.Fill(dt);
for (int k = 0; k < Class1.global_dataset.Tables[0].Rows.Count; k++)
{
if (dt.Rows.Contains(Class1.global_dataset.Tables[0].Rows[k][4].ToString()))
{
MessageBox.Show("Baj Gaya Ghanta!!!!");
}
}
You can use
Linq-To-DataTableto join both tables on this column, for example:(assuming the 5th column and it’s type
int)Note that although
Enumerable.Joinis quite efficient it might be better to compare this in the database instead of loading all into memory.