title: Executing an INSERT command using ASP.net
body: <p>I am using Visual Studio 2010 to create a simple Website for a college assignment. I am trying to create a contact form that submits the users name, email and message to my database table Messages. </p>
  
  <p>I have created the relevant web service and I know that it is working when I try to <code>GET</code> data from the Table. I am just a little confused as to how I can <code>INSERT</code> data into the table.</p>
  
  <p>Below is the code to my web service. The method I am concerned with is <code>addMessage()</code> I call the method when a button is clicked that is located on the contact.aspx page.</p>
  
  <pre><code>    public class Customers : System.Web.Services.WebService {
  
      [WebMethod]
      public DataSet getCustomers() {
          SqlConnection conn;
          SqlDataAdapter myDataAdapter;
          DataSet myDataSet;
          string cmdString = "Select * From Customers";
          conn = new SqlConnection("Data Source=localhost\\SQLEXPRESS;AttachDbFilename=C:\\Users\\n00093500\\Desktop\\MMCA2\\APP_DATA\\NORTHWIND.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
          myDataAdapter = new SqlDataAdapter(cmdString, conn);
          myDataSet = new DataSet();
          myDataAdapter.Fill(myDataSet, "Customers");
          return myDataSet;
      }
  
      [WebMethod]
      public void addMessage(String n, String e, String m)
      {
          SqlConnection conn;
          SqlDataAdapter myDataAdapter;
          SqlCommand myCommand = new SqlCommand("INSERT INTO Messages VALUES("+n+","+e+","+m+")");
          conn = new SqlConnection("Data Source=localhost\\SQLEXPRESS;AttachDbFilename=C:\\Users\\n00093500\\Desktop\\MMCA2\\APP_DATA\\NORTHWIND.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
          //UNSURE WHAT TO DO FROM THIS POINT... CAN I USE myDataAdapter to execute a query?
      }
  
  }
  </code></pre>
  
  <p>Appreciate any help you guys might have! Thanks</p>