(Apologies. I've posted this in the VB .Net section, before I saw a Databases area. Not quite sure where the best place for this is...)
I'm having trouble saving data to a database file. Specifically, saving edits made to records in a data table, via a dataset, using the Update method of a tableadaptermanager. I checked this in multiple sources, but it still doesn't work properly.
I'm using VB .Net 2010 Professional, Windows 7, 64-bit.
My code is below. This version is based on MSDN documentation, Saving Data to a Database (Single Table)
Public Class frmMain
Private Sub PhoneTableBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PhoneTableBindingNavigatorSaveItem.Click
Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'PhoneDataSet.PhoneTable' table. You can move, or remove it, as needed.
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
Catch ex As Exception
I followed the MSDN page referenced above:
used the data configuration wizard
dragged controls from the data sources window to the form
updated the btnSave_Click code to reflect the data objects (e.g. PhoneTable)
Data is being saved to the dataset, but not the actual database file sitting on my hard drive (in the project folder).
I've tried running the program, making an edit to an existing record, click the save button then...
using the next and previous buttons on the binding navigator to progress through records
when I return to the record I edited, the change I saved through btnSave_Click is still there
when I stop debugging and press F5 again, the edited data still appears
BUT...when I press Ctrl+S to save the VB project, then start debugging again, the edited data is no longer there; only the original.
I've checked the Access file and only the original data is there. None of my edits are being saved at all.
Can anyone tell me why this isn't working? The advice on the MSDN page makes sense (and corroborates a number of other resources I used so far), but the Update method of the table adapter seems to be ignored.
Thanks in advance! />/>
Page 1 of 1
1 Replies - 556 Views - Last Post: 24 September 2013 - 06:43 AM
Replies To: Problem Saving Data to Database (Single Table)
Page 1 of 1