Hi ,
Lately i was trying to develop a windows application with c# n sql 2005. i got stucked at a point where i can insert data into the sql db but when i close n open my application, the data is gone. i'll explain briefly,
i've created the sql database(i.e, SKTDB.mdf) and table using server explorer in visual studio 08. my connection string is like ,
sDBPath = Application.StartupPath + "\\DB\\SKTDB.mdf";
if (System.IO.File.Exists(sDBPath))
{
connStr = "Data Source=.\\SQLEXPRESS;AttachDbFilename='" + sDBPath + "';User ID=sa;Password=1234";
}
I have a registration form in my app. when i fill the form and submit , the data is inserted into the table in SKTDB.mdf. but when i restarts my application , the table is empty. I cant figure out the reason. if u guys can , pls let me know..
Loading
Suthish NairPosted Feb 19, 2012, 1:00 PM
Sam HobbsPosted Feb 17, 2012, 11:31 PM
You could do the following for diagnostic purposes. Use the Data Sources window to create a datasource for your table. You can do that in a separate project. Ensure that the datga source works for reading the data. Ensure it works for updating the data. Then look at the connection string and ensure that the connection string that your program creates is consistent with the connections string that was generated by the Data Sources window.
I realize that you need to be able to change the name of the file used or the database, but the procedure I describe might help you learn how to do that so it works.