Blog Home  Home Feed your aggregator (RSS 2.0)  
Software Code Help blogs - Problem: TableAdapter generated by visual studio designer, not saving data in database
newtelligence powered
 
 Thursday, November 13, 2008

Hi.

I have created a Typed Data Set using visual studio 2005 designer. I drag-dropped a table from database and it created a typed data table into it. When I insert data into this table using TableAdapter generated by Visual sudio designer it does not insert in physical database.

I can retrieve it till application is running and lost as the inserted data is in memory not in physical database.

here is the sample code I wrote:

DefectTrackerDataSetTableAdapters.tblDefectsTableAdapter ta = new DefectTracker.DefectTrackerDataSetTableAdapters.tblDefectsTableAdapter();

ta.InsertDefect(Convert.ToInt32(txtDefectNo.Text), "MQC", dpAssignDate.Value, "Open");

 

Thursday, November 13, 2008 4:55:41 AM (GMT Standard Time, UTC+00:00)  #    Comments [1]    | 
Thursday, November 13, 2008 8:25:15 AM (GMT Standard Time, UTC+00:00)
Copy the database file to bin/debug folder.

In brief there are 2 copies of the database: 1 in the application folder and 1 in the bin\debug folder. At design time the database in the app folder is used while at run time the other one.

By default in the solution explorer the database is set to COPY ALWAYS to the bin\debug folder which means that the database is alwys overwritten by the one in the application folder.

Solution:
You can change this property to DO NOT COPY and copy it yourself if when needed or leave the database out of the project. When asked to bring it in the project when creating a connection, sympy say no.

I hope you are as pleased as I am now to have found that annoyance.
Sandeep Bhutani
Name
E-mail
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, strike, strong, sub, sup, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview
Copyright © 2009 Software Code Help. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: