Hi,
I created a table after adding .mdf file to my project. I wrote insert and update query and execute the queries but nothing happed. There is no data added to the table and there is no update action. I did not get any errors.
So please can anybody guide me how to insert and update to sql express using c#
The code I wrote is:
strSql=”update tbl set fldName=’AAA’”;
cmd=new sqlCommand(strSql, conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close()
abdrabaaPosted Jul 15, 2007, 7:03 AM
i get the answer. thats by setting the copy to output directory to copy if newer. Before it was set to copy always.
abdrabaaPosted Jul 15, 2007, 3:45 AM
Hi again,
I used the below code
private void form_Load(object sender, EventArgs e)
{
strSql=”update tbl set fldName=’AAA’”;
cmd=new sqlCommand(strSql, conn);
conn.Open();
cmd.ExecuteNonQuery();
conn.Close()
}
So I changed my code and used button_Click instead of form_load and I was able to insert many rows. But when I close the application and open it again the previous data disappeared like that if I am using blank database.
What I understand that the application creates a copy of the .mdf file while it is running and after closing the application it overwrite the original .mdf file
how to overcome this because I need to use it as database with historical data
Thanks for your time