I am using a .mdf
file for database (SQL Server) and ADO Model in Windows Forms using C#. On a button click, the data is saved into the database, and I have debugged this. But when I close the application, the data vanishes.
Here is my code:
private void btn_add_patientt_Click(object sender, EventArgs e)
{
Doctor doctor = new Doctor
{
First_Name = A_doc_name.Text,
Last_Name = A_doc_last.Text
};
db.Doctors.Add(doctor);
db.SaveChanges();
var v = (from a in db.Doctors select a.Doctor_id).Max();
int x = int.Parse(v.ToString());
MessageBox.Show(x.ToString());
}