saving the changes to a data base file (mdf)  
Author Message
Shauliz





PostPosted: .NET Framework Data Access and Storage, saving the changes to a data base file (mdf) Top

Hi All,

I am new in the DB world so this is probably an easy question.

I am working on a windows project. I created a data base "dataBase.mdf" from MS VC# EE, one of the tables of this DataBase is "tableData". i have created a dataset "coloRightDBDataSet1" with the tableadapter "locationTableAdapter" to access the contents of this table. I also created a dataGridView1 to reflect the tableData Table.
I added rows to the table using the the designer.
When running the program I can see the table and the data I had added throuth the designer.
But when I try to update rows or add new rows the the dataBaseDataSet updates but it does not save it to the underline Database file (dataBase.mdf) - when closing and reopening the program (or when open the data base file) the changes are gone.
just to make sure i am trying to update and and AcceptChanges using -

int numberOfChanegs = this.locationTableAdapter.Update(this.coloRightDBDataSet1.Location);

coloRightDBDataSet1.AcceptChanges();

(I have checked and numberOfChanegs is not 0)

What do i miss

Regards,
Shaul




.NET Development16  
 
 
Andrej Tozon





PostPosted: .NET Framework Data Access and Storage, saving the changes to a data base file (mdf) Top

Hi,

your database file probably gets overwritten by the design-time version. See this FAQ for more detailed explanation and possible solutions...

Also, you don't have to call AcceptChanges() after calling tableadapter's Update method, since this method by default already makes sure it-s called when update is succesfull.

Andrej



 
 
Shauliz





PostPosted: .NET Framework Data Access and Storage, saving the changes to a data base file (mdf) Top

Thansk You Are right the MDF file was "Copy anyways" .....

Thanks again