Advertisement
Guest User

Untitled

a guest
Jan 15th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. public class DBManager
  2. {
  3. private static string connectionString = ConfigurationManager.ConnectionStrings["30322913_DB"].ConnectionString;
  4.  
  5. private SqlConnection cform = new SqlConnection(connectionString);
  6.  
  7. public void addContactForm (ContactForm contactForm)
  8. {
  9. string sqlQuery = "INSERT INTO ContactForm (EmailAddress, FirstName, LastName, Comments, Subscribe)" +
  10. "VALUES ('" + contactForm.getEmailAddress() + " ' , '" + contactForm.getFirstName() + " ' , + '" + contactForm.getLastName() + " ' , " +
  11. " '" + contactForm.getComments() + " ' , ' " + contactForm.getSubscribe() + "' )";
  12.  
  13. SqlCommand cmd = new SqlCommand(sqlQuery, cform);
  14.  
  15. try
  16. {
  17. cform.Open();
  18. cmd.ExecuteNonQuery();
  19. }
  20. catch(Exception ex)
  21. {
  22. string error = ex.Message;
  23. }
  24. finally
  25. {
  26. cform.Close();
  27. }
  28.  
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement