Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB Visual-Studio VB.NET
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 28-Nov-12 4:15am
Comments
Krunal R at 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 :)
Mathlab at 28-Nov-12 10:32am
   
What function are you using to exeecute the query? Executenonquery?
Krunal R at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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[^]
  Permalink  

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 575
1 Kornfeld Eliyahu Peter 409
2 Maciej Los 369
3 DamithSL 196
4 OriginalGriff 188
0 OriginalGriff 6,353
1 DamithSL 4,854
2 Maciej Los 4,476
3 Kornfeld Eliyahu Peter 4,058
4 Sergey Alexandrovich Kryukov 3,917


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 28 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100