Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Dear Coders,

I would like to check once I click on the save button on the Binding Navigator after entering the data in the form whether the data is Inserted into the Database or not. But there is no event in that save button. So Suggest me a solution for achieving it.
Posted
Comments
[no name] 28-Nov-12 9:25am    
Try to count the number of rows before inserting data and after as well.. Compare that value and as per the result show MessageBox... Thats it :)
[no name] 28-Nov-12 10:32am    
What function are you using to exeecute the query? Executenonquery?
[no name] 28-Nov-12 11:02am    
string select = "select* from Employee";
SqlDataAdapter da = new SqlDataAdapter(select, con);
DataTable dt = new DataTable();
da.fill(dt);

int count= dt.Rows.Count;

1 solution

Look at the link below, when you complete your query it will retun the number of rows affected by the query. You can do an if test after that to check to see if the number of rows returned is greater than 0 and perform whatever action you need.

http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.executenonquery(v=VS.71).aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900