Hi,
I am fairly new to VB.net although I have used VBA for a long time.
The issue I am having is am trying to make use of data binding to tie my forms controls / gridviews directly to the data.
I have been following this tutorial (see below) , to the letter, and yet I cannot get the data to save back to the database.
the walk through is "Walkthrough: Saving Data to a Database (Single Table)" foundhere
I set up the database connection, the dataset is created. all is going well. I run the application and the data loads from the database. but anything i add to the database via the bound forms will stay in memory as long as I don't close down visual studio, but once that is close and reopen (or I restart the machine) the data is lost.
I am clicking on the floppy disk icon on the bound controls, and I can see the code below fires. and completes without error.
If is go to the data source and use the "Show Table data" i can see that the data I added is not there.
Am I missing something fundamental from the code below?
Try Me.Validate() Me.CustomersBindingSource.EndEdit() Me.CustomersTableAdapter.Update(Me.NorthwindDataSet.Customers) MsgBox("Update successful") Catch ex As Exception MsgBox("Update failed") End Try
I have tried adding things along the lines of
NorthwindDataSet.Acceptchanges()
, but that doesn't help at all.
I know the solution must be trivial , but I cannot understand why this walk through doesn't work for me.
I have a few versions of VS Express on my machine and SQL Management studio installed also, but I don't see how that would have any effect ?
The code above runs flawlessly, there are no errors flagged, and I don't get any of the syntax errors (the blue squiggly lines i mean)
While I am here, are there any draw back to using databinding in this way. I am not a fan of writing code I don't have to, so setting up SQL commands to delete, insert, update etc. etc. seems silly when I can use this wonderful drag and drop functionality - if it only worked :-) - to make all my data management automatic, clean and error free.
Thanks a million for any suggestions.