Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DBManager
- {
- private static string connectionString = ConfigurationManager.ConnectionStrings["30322913_DB"].ConnectionString;
- private SqlConnection cform = new SqlConnection(connectionString);
- public void addContactForm (ContactForm contactForm)
- {
- string sqlQuery = "INSERT INTO ContactForm (EmailAddress, FirstName, LastName, Comments, Subscribe)" +
- "VALUES ('" + contactForm.getEmailAddress() + " ' , '" + contactForm.getFirstName() + " ' , + '" + contactForm.getLastName() + " ' , " +
- " '" + contactForm.getComments() + " ' , ' " + contactForm.getSubscribe() + "' )";
- SqlCommand cmd = new SqlCommand(sqlQuery, cform);
- try
- {
- cform.Open();
- cmd.ExecuteNonQuery();
- }
- catch(Exception ex)
- {
- string error = ex.Message;
- }
- finally
- {
- cform.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement