Dear all
Even though I have followed the tutorial on data binding gui's on msdn, my installation of vs.vb.net 2k5 doesn't add data.
I've created a table in the sql database, added the dataset, drag and dropped the data table onto the form in detail view. I also entered some test data directly to the database in vs.2k5 enviornment.
Running the program it displays the records in the database.
I've added an msgbox command to display the "updated" records from the form's dataset. Saving new records causes a message to popup giving a new record count, which i assumed added the data to the database. But closing the program and rerunning it, no data has changed!
Equally odd, if i change an existing record and save it, i get an "Invalid Option Exception: Update requires a valid UpdateCommand when passed DataRow collection with modified rows". The same error occurs when i delete a record.
Here is the code for the SaveItem_Click event
---snip---
Private Sub GrammatagramsBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GrammatagramsBindingNavigatorSaveItem.Click
Me.Validate()
Me.GrammatagramsBindingSource.EndEdit()
Dim a As Integer = 0
a = Me.GrammatagramsTableAdapter.Update(Me.Database2DataSet.grammatagrams)
MsgBox("Updated records =" & a)
End Sub
---snip---
Any guidence someone can offer is appreciated. If I can't get it to work I'm gonna have to revert to access 2k (not an option I'm happy about).
Many thanks
Sean

Databinding Doesn't work!?
silvio_at
hi,
this problem happen if you have many tables in your database that related to each other
just for experiment
remove the relationship between the tables in your dataset or try to creat a new project with single table database to test update and delete, if it worked with you can pick solution from those
or during building the relationships in your database force cascading update and cascading delete but this solution is dangerious you can lose lots of data by simple mistake( you will have to recreate your dataset again )
in your form load make your child TableAdapter fill the dataset to force data integrity and in save event handler make poth of table adapters to update, this is a silly solution if you have a big database, but i didn't have a big database to try other solution
best regards
Lukasz Gwozdz
The following does a good job at explaining use of databinding
http://msdn.microsoft.com/library/default.asp url=/library/en-us/dnvs05/html/NETVBdev04.asp
Its part of a free e-book for VB 2005 Development
But for the table adapter to work you much have update, delete and insert queries depending upon the actions you are wanting to allow. You can see if you have them by using the dataset designer and looking at the table adapter properties for these.
If you dont if probable that when you were creating the datasource using the designer that you didnt select to have VB generate these methods for you.
minut
Here is the tutorial link:
http://msdn.microsoft.com/vstudio/express/media/en/AbsoluteBeginner/vb/09VB.wvx
> it only created the select command it did not make the insert, update, and delete commands also.
Oh, that kinda makes sense. I assumed the update statement synchronised the dataset with the database. If you could furnish me with altered code to perform the rest of the actions that would be great!
Thx
Deepak Raghavan
Rob Church
hi,
Is your problem solved If yes then could you please mark reply as answer.
Thank you,
Bhanu.