Reputation: 613
I'am using sqlserver2008.
I have a select query
Con.Open();
String MyQuery="Select * from MyTable where MyField1 is not null";
MySQLDataAdapter=New SqlDataAdapter(MyQuery,Con);
MySQLDataAdapter.Fill(MyTable);
Con.Close();
For (int I1=0;I1<=50;I1++)
{
DataRow DRw = MyTable.NewRow();
MyTable.Rows.Add(DRw); //Null Columns are added
}
blah...blah...blah..
//For Save
MyWMSDatas.VehDAp.Update(MyTable);
Now what I need that, I want ro raise the SqlDataAdapter.RowUpdating()
and would like to update while myField1 is not null and for Null that row should not be update...
Any Ideas ....
Thanks For The Helps
Upvotes: 0
Views: 533
Reputation: 47978
Add a handler to the RowUpdating
event of your adapter:
MyWMSDatas.VehDAp.RowUpdating += VehDAp_RowUpdating
In the handler, check myField1
and set the Status
Property of the argument e
(of type RowUpdatingEventArgs) to UpdateStatus.SkipCurrentRow (or any other value you see more suitable like ErrorsOccurred
...):
private static void OnRowUpdating(object sender, SqlRowUpdatingEventArgs e)
{
if(e.Row....myField1...)
e.Status = UpdateStatus.SkipCurrentRow
....
}
Upvotes: 1