title: ExecuteNonQuery requires the command to have a transaction error in my code
body: <p>I get the following error on <code>cmd.ExecuteNonQuery</code>.</p>
  
  <blockquote>
    <p>"ExecuteNonQuery requires the command to have a transaction when the
    connection assigned to the command is in a pending local transaction. 
    The Transaction property of the command has not been initialized."</p>
  </blockquote>
  
  <p>Here is my code:</p>
  
  <pre><code>  //if (hdRefresh.Value.Length &gt; done.Value.Length || done.Value == "1")
      //{
      //    //Write Your Add Customer Code here &gt; Response.Write("true") 
      //    done.Value = hdRefresh.Value;
      //}
      //else
      //{
      //    Response.Redirect("~/Cashier/BTBill.aspx");
      //    return;
      //}
  
      if (IsClosedToDay())
      {
          ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Warning", "&lt;script&gt;alert('Day Closing has been Performed ')&lt;/script&gt;", false);
          return;
      }
  
      DateTime dateFeomDB = getdate();
      // by atizaz
      if (HDD.Value == "" || HDD.Value == null)
      {
          ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Warning", "&lt;script&gt;alert('No Transaction Found')&lt;/script&gt;", false);
          return;
      }
      //
      SqlConnection scon = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLCONN"].ToString());
      Common.BillTransaction bill1 = new Common.BillTransaction();
      ProcessUpdateBalandUnAuthBal insertBalance = new ProcessUpdateBalandUnAuthBal();
      Common.Currency currencyy = new Common.Currency();
      ProcessAuthorizeTokenByBillNo authorize = new ProcessAuthorizeTokenByBillNo();
      BillTransaction bill = new BillTransaction();
      scon.Open();
      SqlTransaction sqlTrans = scon.BeginTransaction();
      try
      {
          string strforxml = HDD.Value;
          XmlDocument docXml = new XmlDocument();
  
  
          #region Read In To Sender Controlls
  
          #region Common Information
          Contact con = new Contact();
          con.Title = ddlTitle.SelectedItem.Text;
          con.FirstName = TextBox1.Text.Trim();
          con.LastName = TextBox9.Text.Trim();
          con.ConTactNo = txtCell.Text == "" ? SqlString.Null : txtCell.Text;
          con.Country = ddlCountry.SelectedItem.Text;
          con.CustomerType = ddlCustomerType.SelectedItem.Text;
          con.CustTypeID = int.Parse(ddlCustomerType.SelectedValue);
          con.CountryID = Int32.Parse(ddlCountry.SelectedValue);
          con.sqlTransaction = sqlTrans;
          if (Scitytxt.Value != "")
          {
              try
              {
                  con.City = Scitytxt.Value;
                  con.CityID = Int32.Parse(Scityval.Value);
              }
              catch (Exception)
              { }
          }
          else
          {
              con.City = SqlString.Null;// Scitytxt.Value;
              con.CityID = SqlInt32.Null;// Int32.Parse(Scityval.Value);
              con.Address = "";
          }
          //con.City = ddlCity.SelectedItem.Text;
          //con.CityID = int.Parse(ddlCity.SelectedValue);
          con.Address = TextBox10.Text;
          #endregion
  
          #region Check For NIC and Passport
  
          if (txtNIC.Text != "" || txtPassport.Text != "")
          {
              SqlDataReader rdrsender;
  
              if (txtNIC.Text != "")
              {
                  con.NIC = txtNIC.Text;
              }
              else
              {
                  con.NIC = SqlString.Null;
              }
              if (txtPassport.Text != "")
              {
                  con.Passport = txtPassport.Text;
              }
              else
              {
                  con.Passport = SqlString.Null;
              }
              ProcessSearchContactInContactInfo srchSender = new ProcessSearchContactInContactInfo();
              srchSender.Contact = con;
              srchSender.Invokewith5parameters();
              rdrsender = srchSender.ResultSet;
  
              #region If record Doesnot Exist In response of NIC Passport
              if (!rdrsender.Read())
              {
                  rdrsender.Close();
                  rdrsender.Dispose();
                  //  con.sqlTransaction = sqlTrans;
                  ProcessAddContact InsertnewSenderInfo = new ProcessAddContact();
                  // InsertnewSenderInfo.sqlTransaction = sqlTrans;
                  InsertnewSenderInfo.Contact = con;
                  InsertnewSenderInfo.Invoke();
  
                  //  sender1 = InsertnewSenderInfo.ResultSet;
                  //  Sender_ID.Value = sender1[13].ToString();
              }
              #endregion
              #region If Record Exists
              else
              {
                  con.CustomerID = Int32.Parse(rdrsender["Customer_ID"].ToString());
                  rdrsender.Close();
                  rdrsender.Dispose();
              }
              #endregion
          }
          #endregion
  
          #region If Customer Donot Have NIC And/OR Passport
          else// this executes when both Pasport and NIC are Null
          {
              con.NIC = SqlString.Null;
              con.Passport = SqlString.Null;
              ProcessAddContact InsertnewSenderInfo = new ProcessAddContact();
              InsertnewSenderInfo.Contact = con;
              InsertnewSenderInfo.Invoke();
  
              DataSet ds = new DataSet();
              int a = con.CustomerID;
              StringReader inforeader = new StringReader("&lt;CusTable&gt;&lt;CusInfo&gt;&lt;Relation_Type&gt;&lt;/Relation_Type&gt;&lt;HusbandFather_Name&gt;&lt;/HusbandFather_Name&gt;&lt;Address_Present&gt;&lt;/Address_Present&gt;&lt;Address_Other&gt;&lt;/Address_Other&gt;&lt;Phone_No_Office&gt;&lt;/Phone_No_Office&gt;&lt;Cell_No&gt;&lt;/Cell_No&gt;&lt;Fax_No&gt;&lt;/Fax_No&gt;&lt;Date_Of_Birth&gt;&lt;/Date_Of_Birth&gt;&lt;NTN_No&gt;&lt;/NTN_No&gt;&lt;Nationality&gt;&lt;/Nationality&gt;&lt;Occupation&gt;&lt;/Occupation&gt;&lt;Relation_With_Financial_Institution&gt;&lt;/Relation_With_Financial_Institution&gt;&lt;Other_Relation_With_Financial_Institution&gt;&lt;/Other_Relation_With_Financial_Institution&gt;&lt;Business_Relation&gt;&lt;/Business_Relation&gt;&lt;/CusInfo&gt;&lt;/CusTable&gt;");
              ds.ReadXml(inforeader);
              ds.GetXml();
              SqlCommand cmd = new SqlCommand("update Contact_Info set CustInfo=" + ds.GetXml() + " WHERE Customer_ID=" + a + "", scon);
              cmd.ExecuteNonQuery();
  
              //  sender1 = InsertnewSenderInfo.ResultSet;
              //  Sender_ID.Value = sender1[13].ToString();
          }
  </code></pre>
  
  <p>tell me what is problem in my code and how to solve it.</p>