I attached the service-based database to my windows application and I used the following code to save the data, it is working correctly, but when I close the application and open again the data which I saved was cleared automatically.
How to save the data permanently...
string c = Application.StartupPath + "\\Stock.mdf";
SqlConnection con = new SqlConnection(@"AttachDbFilename='"+c+"';Integrated Security=True;Connect Timeout=30;User Instance=True");
con.Open();
SqlCommand cmd = new SqlCommand("Insert into Codedetails values('TF','" + txt_productcode.Text + "','" + txt_productname.Text + "','" + txt_brandcode.Text + "','" + txt_brandname.Text + "')", con);
cmd.ExecuteNonQuery();
con.Close();