title: calling 2 methods from onclick c#
body: <p>Ive been trying to pass 2 SQL queries by clicking the button once and so this is what ive been trying to do as shown below but its not working....please help... thanks in advance</p>
  
  <p>so this the code in front </p>
  
  <p><code>&lt;asp:Button ID="btnWedRecInsert" runat="server" Text="Insert" OnClick="btnWedRecInsert_Click1; btnWedRecInsert_Click2;" /&gt;</code></p>
  
  <p>The code behind is below</p>
  
  <pre><code>protected void btnWedRecInsert_Click1(object sender, EventArgs e)
  { 
  
      string Function = ddlFunction.Text;
      string FunctionDate = txtFunctionDate.Text;
      string FunctionTime = ddlFunctionTime.Text;
      string groomName = txtGroomName.Text;
      string groomFatherName = txtGroomFatherName.Text;
      string groomAge = txtGroomAge.Text;
      string groomPhone = txtGroomPhone.Text;
      string groomAddress = txtGroomAddress.Text;
      string brideName = txtBrideName.Text;
      string brideFatherName = txtBrideFatherName.Text;
      string brideAge = txtBrideAge.Text;
      string bridePhone = txtBridePhone.Text;
      string brideAddress = txtBrideAddress.Text;
      string registerName = txtRegisterName.Text;
      string registerPhone = txtRegisterPhone.Text;
      string registerAddress = txtRegisterAddress.Text;
      string referenceName = txtReferenceName.Text;
      string referencePhone = txtReferencePhone.Text;
      string referenceAddress = txtReferenceAddress.Text;
  
  
  
      string connString = ConfigurationManager.ConnectionStrings["MandapamDatabase"].ConnectionString;
      OleDbConnection connection = new OleDbConnection(connString);
      string insertQuery = "INSERT INTO wedding(RegisteredDate, Function, FunctionDate, FunctionTime, groomName, groomFatherName, groomAge, groomPhone, groomAddress, brideName, brideFatherName, brideAge, bridePhone, brideAddress, registerName, registerPhone, registerAddress, referenceName, referencePhone, referenceAddress) VALUES( @Date, @Function, @FunctionDate, @FunctionTime, @groomName, @groomFatherName, @groomAge, @groomPhone, @groomAddress, @brideName, @brideFatherName, @brideAge, @bridePhone, @brideAddress, @registerName, @registerPhone, @registerAddress, @referenceName, @referencePhone, @referenceAddress) ";
      OleDbCommand command = new OleDbCommand();
      command.Connection = connection;
      command.CommandText = insertQuery;
      command.CommandType = CommandType.Text;
      command.Parameters.AddWithValue("@Date", DateTime.Now.Date);
      command.Parameters.AddWithValue("@Function", Function);
      command.Parameters.AddWithValue("@FunctionDate", FunctionDate);
      command.Parameters.AddWithValue("@FunctionTime", FunctionTime);
      command.Parameters.AddWithValue("@groomName", groomName);
      command.Parameters.AddWithValue("@groomFatherName", groomFatherName);
      command.Parameters.AddWithValue("@groomAge", groomAge);
      command.Parameters.AddWithValue("@groomPhone", groomPhone);
      command.Parameters.AddWithValue("@groomAddress", groomAddress);
      command.Parameters.AddWithValue("@brideName", brideName);
      command.Parameters.AddWithValue("@brideFatherName", brideFatherName);
      command.Parameters.AddWithValue("@brideAge", brideAge);
      command.Parameters.AddWithValue("@bridePhone", bridePhone);
      command.Parameters.AddWithValue("@brideAddress", brideAddress);
      command.Parameters.AddWithValue("@registerName", registerName);
      command.Parameters.AddWithValue("@registerPhone", registerPhone);
      command.Parameters.AddWithValue("@registerAddress", registerAddress);
      command.Parameters.AddWithValue("@referenceName", referenceName);
      command.Parameters.AddWithValue("@referencePhone", referencePhone);
      command.Parameters.AddWithValue("@referenceAddress", referenceAddress);
  
  
      try
      {
          connection.Open();
          command.ExecuteNonQuery();
          lblMessage.Text = "Record inserted successfully";
      }
      catch (Exception ex)
      {
          lblMessage.Text = "Unable to insert record";
      }
      finally
      {
          connection.Close();
      }
  }
  
  
      protected void btnWedRecInsert_Click2(object sender, EventArgs e)
      {
          string Function = ddlReception.Text;
          string FunctionDate = txtReceptionDate.Text;
          string FunctionTime = ddlReceptionTime.Text;
          string groomName = txtGroomName.Text;
          string groomFatherName = txtGroomFatherName.Text;
          string groomAge = txtGroomAge.Text;
          string groomPhone = txtGroomPhone.Text;
          string groomAddress = txtGroomAddress.Text;
          string brideName = txtBrideName.Text;
          string brideFatherName = txtBrideFatherName.Text;
          string brideAge = txtBrideAge.Text;
          string bridePhone = txtBridePhone.Text;
          string brideAddress = txtBrideAddress.Text;
          string registerName = txtRegisterName.Text;
          string registerPhone = txtRegisterPhone.Text;
          string registerAddress = txtRegisterAddress.Text;
          string referenceName = txtReferenceName.Text;
          string referencePhone = txtReferencePhone.Text;
          string referenceAddress = txtReferenceAddress.Text;
  
  
  
          string connString = ConfigurationManager.ConnectionStrings["MandapamDatabase"].ConnectionString;
          OleDbConnection connection = new OleDbConnection(connString);
          string insertQuery = "INSERT INTO wedding(RegisteredDate, Function, ReceptionTime, FunctionDate, FunctionTime, groomName, groomFatherName, groomAge, groomPhone, groomAddress, brideName, brideFatherName, brideAge, bridePhone, brideAddress, registerName, registerPhone, registerAddress, referenceName, referencePhone, referenceAddress) VALUES( @Date, @Function, @FunctionDate, @FunctionTime, @groomName, @groomFatherName, @groomAge, @groomPhone, @groomAddress, @brideName, @brideFatherName, @brideAge, @bridePhone, @brideAddress, @registerName, @registerPhone, @registerAddress, @referenceName, @referencePhone, @referenceAddress) ";
          OleDbCommand command = new OleDbCommand();
          command.Connection = connection;
          command.CommandText = insertQuery;
          command.CommandType = CommandType.Text;
          command.Parameters.AddWithValue("@Date", DateTime.Now.Date);
          command.Parameters.AddWithValue("@Function", Function);
          command.Parameters.AddWithValue("@FunctionDate", FunctionDate);
          command.Parameters.AddWithValue("@FunctionTime", FunctionTime);
          command.Parameters.AddWithValue("@groomName", groomName);
          command.Parameters.AddWithValue("@groomFatherName", groomFatherName);
          command.Parameters.AddWithValue("@groomAge", groomAge);
          command.Parameters.AddWithValue("@groomPhone", groomPhone);
          command.Parameters.AddWithValue("@groomAddress", groomAddress);
          command.Parameters.AddWithValue("@brideName", brideName);
          command.Parameters.AddWithValue("@brideFatherName", brideFatherName);
          command.Parameters.AddWithValue("@brideAge", brideAge);
          command.Parameters.AddWithValue("@bridePhone", bridePhone);
          command.Parameters.AddWithValue("@brideAddress", brideAddress);
          command.Parameters.AddWithValue("@registerName", registerName);
          command.Parameters.AddWithValue("@registerPhone", registerPhone);
          command.Parameters.AddWithValue("@registerAddress", registerAddress);
          command.Parameters.AddWithValue("@referenceName", referenceName);
          command.Parameters.AddWithValue("@referencePhone", referencePhone);
          command.Parameters.AddWithValue("@referenceAddress", referenceAddress);
  
  
          try
          {
              connection.Open();
              command.ExecuteNonQuery();
              lblMessage.Text = "Record inserted successfully";
          }
          catch (Exception ex)
          {
              lblMessage.Text = "Unable to insert record";
          }
          finally
          {
              connection.Close();
          }
      }
  </code></pre>