Writing simple data from DataSet to Database?

Bisto

Member
Joined
Jan 25, 2007
Messages
6
Programming Experience
Beginner
Hi people,
I am a VB.NET/ADO beginner and i'm having trouble with DataSets. I have basically created a simple form to which I dragged and dropped some text boxes from a Database I made. This worked fine and using the Navigation bar that Visual Studio (2005 Pro) creates automatically I can navigate forward and backwards. However, when I add a record and try to save it, it does not save to the database. As you will know, this means when the program is closed, all changes are lost.

The code from the Save button is below.
VB.NET:
Private Sub Tbl_HouseBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Tbl_HouseBindingNavigatorSaveItem.Click
Me.Validate()
Me.Tbl_HouseBindingSource.EndEdit()
Me.Tbl_HouseTableAdapter.Update(Me.HouseDataSet.tbl_House)
 
End Sub

Please can someone tell me where I am going wrong?

TIA,
Bisto
 
Last edited by a moderator:
What's your code for trying to add the record?

EDIT
Sorry, what I meant is how are you calling a new row to be inserted?

When you click your "insert" button, use

VB.NET:
me.Tbl_HouseTableAdapter.endedit()
me.Tbl_HouseTableAdapter.addnew()

Your Save button looks OK, try adding the code above to the insert button, save and see what happens....
 
As you will know, this means when the program is closed, all changes are lost.

If you are using a file based database like access or a sqlserver mdf file, then you should search the forum for "Copy if newer"

The "my database is not saving data" complaint comes up several times per week and explaining it all the time is getting tiring.. read what the search brings up and if it doesnt help, come back
 
@ VB_New-B

Shouldn't you call .addnew and .endedit on the bindingsource, not the tableadapter?
 
Back
Top