DataBinding

I am going through the Learning Resources by Bab Tabor. Lesson 9 is about databinding. The culmination of the whole lesson developing a simple application where you can use a form to change data in the original SQL database. When I build my own program based on the specific example outlined in the lesson, the changes I make in the form are never updated into the original database. So, I go and download the solution and the same thing happens, the data in the original database (in the example MyCompany) is never updated.

Any guidance?

[542 byte] By [Babroberg] at [2008-2-15]
# 1
There are actually two copies of the database: one in the app directory, which is the one you work with from the IDE, and one in the output directory, which is the one you work with when the program is running. By default, VB copies the app version to the output directory whenever you start your program. Then you make your changes and save them. All is well, until you restart the program. Then the app version gets copied again and wipes out your changes.

The solution is to select your database.mdf file in the solution explorer, and set its "copy to output" property to "do not copy". You may need to do some manual copying if you want to make changes via the IDE, but your runtime changes will be preserved.

--Mable

Mable at 2007-9-8 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 2
This solution produces an error
An attempt to attach an auto-named database for file..........
Any thoughts?
Jonsey at 2007-9-8 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 3
Mable wrote:
There are actually two copies of the database: one in the app directory, which is the one you work with from the IDE, and one in the output directory, which is the one you work with when the program is running. By default, VB copies the app version to the output directory whenever you start your program. Then you make your changes and save them. All is well, until you restart the program. Then the app version gets copied again and wipes out your changes.

The solution is to select your database.mdf file in the solution explorer, and set its "copy to output" property to "do not copy". You may need to do some manual copying if you want to make changes via the IDE, but your runtime changes will be preserved.

--Mable


Setting it to "copy if newer" works
Jonsey at 2007-9-8 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 4
Thanks a million.Big Smile
Babroberg at 2007-9-8 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...
# 5
Thank you Jonsey! I have been stuck on this for a while.

Eviakhan at 2007-9-8 > top of Msdn Tech,Visual Studio Express Editions,Visual Basic 2005 Express Edition...