By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,524 Members | 1,475 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,524 IT Pros & Developers. It's quick & easy.

Save changes in datagrid

P: 1
I typed this codes in a button, but this codes not work:
Expand|Select|Wrap|Line Numbers
  1. Dim Save As New DataSet
  2. Save = BGKCDataset.GetChanges()
  3. Try
  4.   If Not (Save Is Nothing) Then
  5.     BGKCCentralDatasSqlDataAdapter.Update(Save)
  6.     BGKCCentralDatasSqlDataAdapter.Fill(BGKCDataset.Tbl_BGKCCentralDatas)
  7.   End If
  8. Catch ex As Exception
  9.   MsgBox(ex.Message)
  10. End Try
Can you help me save changes in this problem?

Aug 9 '12 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 9,731
Well I'm not sure why it's not working.
Did you check the database and it isn't updated?
Did you get some sort of exception when running the code?
What is the error message?

The only thing that I noticed is that you are declaring a Save as a New DataSet when you don't need to.

You could just have:
Expand|Select|Wrap|Line Numbers
  1. Dim Save As DataSet = BGKCDataset.GetChanges()
  2. Try
  3.   If Not (Save Is Nothing) Then
  4.     BGKCCentralDatasSqlDataAdapter.Update(Save)
  5.     BGKCCentralDatasSqlDataAdapter.Fill(BGKCDataset.Tbl_BGKCCentralDatas)
  6.   Else
  7.     MessageBox.Show("There were no changes")
  8.   End If
  9. Catch ex As Exception
  10.   MsgBox(ex.Message)
  11. End Try
Please post more details about what the problem is so that we can help you more.

Aug 10 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.