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

Getting Data to Save to Database

P: 3
I am new to programming and am sorry if this post is in the wrong area. I have a listbox bound to a table and a datagrid bound to another one with a connection through xml. I can change the data within the grid, with the following through a button on a different tab page within the form, but it does not save changes to the database, just shows them on the datagrid until the program is closed:
Expand|Select|Wrap|Line Numbers
  1. 'Temporary Datasets to store the inserted or modified rows
  2. Dim pdsInsertedRows, pdsModifiedRows As DataSet
  3.  
  4. 'Set the menu items to indicate that a record is being edited
  5. Call EditState(cblnNotEditing)
  6.  
  7. 'End editing on current record
  8. Me.BindingContext(DsClientServiceBinding1). _
  9. EndCurrentEdit()
  10.  
  11. 'copy the DataSet by getting the added or modified records from the
  12. 'origional bound Dataset
  13. pdsInsertedRows = DsClientServiceBinding1.GetChanges(DataRowState.Added)
  14. pdsModifiedRows = DsClientServiceBinding1.GetChanges(DataRowState.Modified)
  15.  
  16. 'Check to see if there is modified rows.  If there is update the Dataset
  17. If Not pdsModifiedRows Is Nothing Then
  18.     odbdaTickets1.Update (pdsModifiedRows)
  19. End If
  20.  
  21. 'Check to see if there are inserted rows and update
  22. If Not pdsInsertedRows Is Nothing Then
  23.     odbdaTickets1.Update (pdsInsertedRows)
  24. End If
  25.  
  26. 'Synchronize the database with the Dataset by accepting changes
  27. DsClientServiceBinding1.AcceptChanges()
  28.  
Thank you in advance for your help,
Apr 4 '07 #1
Share this Question
Share on Google+
4 Replies


Dököll
Expert 100+
P: 2,364
I am new to programming and am sorry if this post is in the wrong area. I have a listbox bound to a table and a datagrid bound to another one with a connection through xml. I can change the data within the grid, with the following through a button on a different tab page within the form, but it does not save changes to the database, just shows them on the datagrid until the program is closed:

'Temporary Datasets to store the inserted or modified rows
Dim pdsInsertedRows, pdsModifiedRows As DataSet

'Set the menu items to indicate that a record is being edited
Call EditState(cblnNotEditing)

'End editing on current record
Me.BindingContext(DsClientServiceBinding1). _
EndCurrentEdit()

'copy the DataSet by getting the added or modified records from the
'origional bound Dataset
pdsInsertedRows = DsClientServiceBinding1.GetChanges(DataRowState.Ad ded)
pdsModifiedRows = DsClientServiceBinding1.GetChanges(DataRowState.Mo dified)

'Check to see if there is modified rows. If there is update the Dataset
If Not pdsModifiedRows Is Nothing Then
odbdaTickets1.Update(pdsModifiedRows)
End If

'Check to see if there are inserted rows and update
If Not pdsInsertedRows Is Nothing Then
odbdaTickets1.Update(pdsInsertedRows)
End If

'Synchronize the database with the Dataset by accepting changes
DsClientServiceBinding1.AcceptChanges()

Thank you in advance for your help,
Greetings and salutations!

I think this is what you want, looked through it myself. You'll need to do some reading:

http://www.codeproject.com/cs/databa...select=1644938

In a bit, and have fun with the project...
Apr 5 '07 #2

P: 3
Greetings and salutations!

I think this is what you want, looked through it myself. You'll need to do some reading:

http://www.codeproject.com/cs/databa...select=1644938

In a bit, and have fun with the project...
I am not sure I understand it. I have the connection, it reads the two tables, it lets me update and shows the changes in the tables on the form, but not in the database itself. Do I need to close and reopen the connection to update the actual database? Or am I missing something?
Apr 5 '07 #3

Dököll
Expert 100+
P: 2,364
I am not sure I understand it. I have the connection, it reads the two tables, it lets me update and shows the changes in the tables on the form, but not in the database itself. Do I need to close and reopen the connection to update the actual database? Or am I missing something?
Excuse the confusion. You are adding back to the database (updated data is being added to the database). Do you have a "Save" or Add to Databse" button? or something in that kind of a line! Do the data you have updated through xml have texboxes specific to them on your form? Your button to Add or Save should send to your database.

Perhpas this one is easier to understand, look up the insert command:

http://blogs.msdn.com/codemouse/default.aspx

Write again if not helpful...
Apr 5 '07 #4

P: 3
Excuse the confusion. You are adding back to the database (updated data is being added to the database). Do you have a "Save" or Add to Databse" button? or something in that kind of a line! Do the data you have updated through xml have texboxes specific to them on your form? Your button to Add or Save should send to your database.

Perhpas this one is easier to understand, look up the insert command:

http://blogs.msdn.com/codemouse/default.aspx

Write again if not helpful...
I have an update button. The textboxes are tied through xml table relation. Does saving to the dataset not save to the database? I appreciate your help.
Apr 5 '07 #5

Post your reply

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