I'm beginer in vb and i'm practicing in a small project where I need to store the data to the database..

I already create the database and thru tableadapter I access data into the form but when I change the data and save thru bindingnavigator save button; it does update the data set but doesn't update the database table.

So when again I load the form it shows the original data again i.e nonupdated datas. Can somebody guide me what to do

Re: Visual Basic General VB DAtabase connect

Riquel Dong ¨C MSFT

Hi Renshi,

Based on your post, my understanding of your question is that when your application saves the data change, but the data isn't saved into the database.

Do you use the local database files When you are working with local database files, at design-time the application uses database file in the project folder. At run-time, the application will use the database file under the output folder. As a result of the copy, we have the impression that the app doesn't save the data to the database file. In fact, this is simply because there are two copies of the data file involved. Same applies when looking at the schema/data through the database explorer. The tools are using the copy in the project, not the one in the bin folder.

If this copy behavior is not what you want, there are few ways to work around it:

1. If you select local database file in the Solution Explorer window, you will see a property called ¡®Copy to Output¡¯ in the Properties window. By default it is set to ¡®Copy Always¡¯ which means that on each build, the data files in the project folder will be copied to the output folder overwriting the existing data files if any. You can set this property to Copy Never and then manually put a copy of the data file in the output folder. This way, on subsequent builds, the project system will leave the datafile in the output folder and not try to overwrite it with the one from the project. The downside is that you still have two copies so after you modify the database file using the app, if you want to work on those changes in the project, you need to copy it to the project manually and vise-versa.

2. You can leave the data file outside the project and create a connection to it in Database Explorer. When the IDE asks you to bring the file into the project, just say no. This way, both the design-time and the run-time will be using the same data file but the downside is that the path in the connection string will be hard coded and therefore it¡¯ll be harder to share the project and deploy the app. Before deploying the app, just make sure to replace the full path in the settings with a relative path.

Hope this helps. If you have any further questions, please tell me. For more information about working with local databases, please visit:

Best regards,