SHARE
TWEET

Untitled

a guest Jan 15th, 2020 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top