Question BindingSource AddNew not working

belle@twookies.com

New member
Joined
Jul 6, 2010
Messages
3
Programming Experience
Beginner
When I try to add a new record to my bindingsource it seems to work fine and tells me that I have updated one new record. But when I come back later, the record doesn't exist in the database. The database key field is an autoincrementing field - that may be my problem? If so any ideas on how to get around this?

My command to add a new record
MoviesBindingSource.AddNew()
this creates blank fields on my form1, (the primary key shows as -1) then when you fill in the form and save the record with the following command
Validate()
MoviesBindingSource.EndEdit()
Dim i = MoviesTableAdapter.Update(MoviesDataSet.Movies)
MsgBox(" Records updated in Movies table = " & i)
It shows one record has been updated.

If you view the records on the form, the new record appears to exist in the datatable

But if you close the program, and restart it, the new record doesn't exist in the database.

Also if you preview the records in the database (MoviesDataSet.xsd) in the solution explorer, the new record doesn't exist.

I also get no errors in the immediate window, so I don't think I have any conversion type errors.

Any ideas?
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,602
Location
Sydney, Australia
Programming Experience
10+
Everything is working exactly as it should. The data is being saved fine. You're just overwriting the database each time you run the project. Follow the first link in my signature for more information on managing local data files.
 

belle@twookies.com

New member
Joined
Jul 6, 2010
Messages
3
Programming Experience
Beginner
Thanks so much for your response.
I spent two days trying to find a solution to this problem on various forums with no luck.
Goes to show you that have to ask the right question to the right person!
Thanks again!
Jim Anthony
 
Top Bottom