Problem saving data with sql 2005 express

I am new to VB2005 express. I’m following the videos from: http://msdn.microsoft.com/vstudio/express/vb/learning/

All was good until lesson 9, working with a simple master/details form. I change data from a register (i.e. "Chuck" to "Charles"), save the changes and aparently everything work, but when I restart the programa the changes were not saved in the database ("Chuck still appears").

I even download and install the visual basic project from the site with which the videos were made, but still got the same problem.

I'm using a Dataset, TableAdapter and BindingSource, the code to save changes is:

dim RowsAffected as integer=0

BindingSource1.EndEdit()

RowsAffected=CustomerTableAdapter1.Update(MyCompanyDataSet1.customer)

messagebox.show(RowsAffected.toString())

The messagebox shows 1, and the changes are made, but when restarted they dissapear.

What am I missing

Thanks.



Answer this question

Problem saving data with sql 2005 express

  • sbondale

    If you'll look on the FAQ at the top of the forum, I thnk you'll find that the reason this is happening is because when you run a program, your database is copied to the debug directory, then you change it and everything works. Next, you restart the application, the database is re-copied over to the debug directory, so the database overwrites the database that you had changed.

    Check the FAQ on how to fix this.

  • Ernie_Quest

    Thank you Lydon, you were right. I find the answer to my problem at this repost:

    http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=159772&SiteID=1

    Para las personas de habla hispana, esta solucion en espanol es:

    Click derecho sobre la base de datos en el "Explorador de Soluciones",

    En la propiedad "Copiar en el Directorio", seleccionar "Copiar si es posterior". De esta forma la base de datos solo se sobreescribe cuando han habido cambios en su estructura.

    Mauricio.


  • Problem saving data with sql 2005 express