Guest User

Untitled

a guest
Jan 15th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. SqlCeConnection con = new SqlCeConnection(@"Data Source=C:UsersTomDocumentsTheParlour.sdf;Password=theparlour;Persist Security Info=True");
  2. SqlCeCommand cmd = new SqlCeCommand();
  3. cmd.Connection = con;
  4. cmd.CommandType = CommandType.Text;
  5.  
  6. 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)";
  7. cmd.Parameters.AddWithValue("@Title", cmbTitle.Text);
  8. cmd.Parameters.AddWithValue("@Forename", txtForename.Text);
  9. cmd.Parameters.AddWithValue("@Initial", txtInitial.Text);
  10. cmd.Parameters.AddWithValue("@Surname", txtSurname.Text);
  11. cmd.Parameters.AddWithValue("@DOB", dtpDOB.Text);
  12. cmd.Parameters.AddWithValue("@AddL1", txtAddL1.Text);
  13. cmd.Parameters.AddWithValue("@AddL2", txtAddL2.Text);
  14. cmd.Parameters.AddWithValue("@AddL3", txtAddL3.Text);
  15. cmd.Parameters.AddWithValue("@Town", txtTown.Text);
  16. cmd.Parameters.AddWithValue("@County", txtCounty.Text);
  17. cmd.Parameters.AddWithValue("@Postcode", txtPostcode.Text);
  18. cmd.Parameters.AddWithValue("@Telephone", txtTel.Text);
  19. cmd.Parameters.AddWithValue("@Mobile", txtMob.Text);
  20. cmd.Parameters.AddWithValue("@Email", txtEmail.Text);
  21.  
  22. try
  23. {
  24. con.Open();
  25. cmd.ExecuteNonQuery();
  26. }
  27. catch
  28. {
  29. MessageBox.Show("fail");
  30. }
  31. finally
  32. {
  33. con.Close();
  34. cmd.Dispose();
  35. }
Add Comment
Please, Sign In to add comment