SqlConnection con = new SqlConnection("Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=C:\....\\Database.mdf;Integrated Security=True;Connect Timeout=30");
con.Open();
SqlCommand insertPatient = new SqlCommand("INSERT INTO patients (phone, firstname, lastname, address_ID) VALUES (@phoneNumb, @firstname, @lastname, @address_ID", con);
insertPatient.Parameters.AddWithValue("@phoneNumb", this.phoneTextBox.Text);
insertPatient.Parameters.AddWithValue("@firstname", this.firstNameBox.Text);
insertPatient.Parameters.AddWithValue("@lastname", this.firstNameBox.Text);
insertPatient.Parameters.AddWithValue("@address_ID", this.comboBox1.SelectedIndex.ToString());
Console.WriteLine(this.comboBox1.SelectedIndex);
int i = insertPatient.ExecuteNonQuery();
con.Close(); SqlConnection con = new SqlConnection("Data Source=(LocalDB)\\MSSQLLocalDB;AttachDbFilename=C:\\...Database.mdf;Integrated Security=True;Connect Timeout=30");
con.Open();
SqlCommand insertPatient = new SqlCommand("INSERT INTO patients (phone, firstname, lastname, address_ID) VALUES (@phoneNumb, @firstname, @lastname, @address_ID", con);
insertPatient.Parameters.AddWithValue("@phoneNumb", this.phoneTextBox.Text);
insertPatient.Parameters.AddWithValue("@firstname", this.firstNameBox.Text);
insertPatient.Parameters.AddWithValue("@lastname", this.firstNameBox.Text);
insertPatient.Parameters.AddWithValue("@address_ID", this.comboBox1.SelectedIndex.ToString());
Console.WriteLine(this.comboBox1.SelectedIndex);
int i = insertPatient.ExecuteNonQuery();
con.Close();