Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SqlCeConnection con = new SqlCeConnection(@"Data Source=C:UsersTomDocumentsTheParlour.sdf;Password=theparlour;Persist Security Info=True");
- SqlCeCommand cmd = new SqlCeCommand();
- cmd.Connection = con;
- cmd.CommandType = CommandType.Text;
- cmd.CommandText = @"INSERT INTO ClientContact (Title,Forename,Initial,Surname,DOB,AddressLine1,AddressLine2,AddressLine3,Town,County,Postcode,Telephone,Mobile,Email) VALUES(@Title,@Forename,@Initial,@Surname,@DOB,@AddL1,@AddL2,@AddL3,@Town,@County,@Postcode,@Telephone,@Mobile,@Email)";
- cmd.Parameters.AddWithValue("@Title", cmbTitle.Text);
- cmd.Parameters.AddWithValue("@Forename", txtForename.Text);
- cmd.Parameters.AddWithValue("@Initial", txtInitial.Text);
- cmd.Parameters.AddWithValue("@Surname", txtSurname.Text);
- cmd.Parameters.AddWithValue("@DOB", dtpDOB.Text);
- cmd.Parameters.AddWithValue("@AddL1", txtAddL1.Text);
- cmd.Parameters.AddWithValue("@AddL2", txtAddL2.Text);
- cmd.Parameters.AddWithValue("@AddL3", txtAddL3.Text);
- cmd.Parameters.AddWithValue("@Town", txtTown.Text);
- cmd.Parameters.AddWithValue("@County", txtCounty.Text);
- cmd.Parameters.AddWithValue("@Postcode", txtPostcode.Text);
- cmd.Parameters.AddWithValue("@Telephone", txtTel.Text);
- cmd.Parameters.AddWithValue("@Mobile", txtMob.Text);
- cmd.Parameters.AddWithValue("@Email", txtEmail.Text);
- try
- {
- con.Open();
- cmd.ExecuteNonQuery();
- }
- catch
- {
- MessageBox.Show("fail");
- }
- finally
- {
- con.Close();
- cmd.Dispose();
- }
Add Comment
Please, Sign In to add comment