title: C# code executed successfully with SQL but when checked in Database they are still showing null values
body: <p>**My data has to be saved from various text boxes but what happened is that when i try to save there is no error message but the problem for me is that data is not getting posted to SQL database,
  all of its values are showing null when checked in SQL tables</p>
  <p>My Save button function is as follows**</p>
  <pre><code> private void btnsavebill_Click(object sender, EventArgs e)
      {
          transactionBLL transaction = new transactionBLL();
          transaction.type = lblpurchasehead.Text;
  
          //get the ID of the dealer or customer HEre
          // get the name of the dealer or custoemr name
          string deacustname = txtdlrname.Text;
          dealerBLL dc = dcdal.getdeacustIDfromName(deacustname);
  
          transaction.date_cust_id = dc.id;
          transaction.grandtotal = Math.Round(decimal.Parse(txtgrandtotal.Text), 2);
          transaction.transaction_date = DateTime.Now;
          transaction.tax = decimal.Parse(txtgstper.Text);
          transaction.discount = decimal.Parse(txtDiscountbill.Text);
  
          //get user name of logged in user name
          string username = frmLogin.loggedIn;
          userBLL u = udal.GetIDFromUsername(username);
  
          transaction.added_by = u.id;
          transaction.transactiondetail = transactionDT;
  
          // creating a boolean variable and set value to false
          bool success = false;
  
          //Actual cocde to insert trans and trans DT
  
          using TransactionScope scope = new TransactionScope();
          {
              int transactionId = -1;
  
              bool w = tdal.Insert_Transaction(transaction, out transactionId);
  
  
              //use for loop to insert transaction details
  
              for (int i = 0;i&lt;transactionDT.Rows.Count;i++)
              {
                  //get all the details of products
                  transactiondetailBLL transactiondetail = new transactiondetailBLL();
  
                  //get the product name and convert it into ID
                  string ProductName = transactionDT.Rows[i][0].ToString();
  
                  productsBLL p = pdal.getproductsIDfromName(ProductName);
                  
                  transactiondetail.product_int = p.id;
                  transactiondetail.rate = decimal.Parse(transactionDT.Rows[i][1].ToString());
                  transactiondetail.qty = decimal.Parse(transactionDT.Rows[i][2].ToString());
                  transactiondetail.total = Math.Round(decimal.Parse(transactionDT.Rows[i][3].ToString()), 2);
                  transactiondetail.dec_cust_id = dc.id;
                  transactiondetail.added_date = DateTime.Now;
                  transactiondetail.added_by = u.id;
  
                  //Insert transaction Detail inside our Database
                  bool y = tddal.InsertTransactionDetail(transactiondetail);
                  success = w &amp;&amp; y;
              }
              if (success == true)
              {
                  //transaction complete
                  MessageBox.Show(&quot;Transaction completed successfully to details table&quot;);
                  //clear data grid view
                  dgvaddprodforbill.DataSource = null;
                  dgvaddprodforbill.Rows.Clear();
  
                  //clear all other values
  
                  txtdlrSearch.Text = &quot;&quot;;
                  txtdlremail.Text = &quot;&quot;;
                  txtdlrname.Text = &quot;&quot;;
                  txtdlrcontact.Text = &quot;&quot;;
                  txtdlraddress.Text = &quot;&quot;;
                  txtproductsearch.Text = &quot;&quot;;
                  txtproname.Text = &quot;&quot;;
                  txtproinventory.Text = &quot;&quot;;
                  txtproprice.Text = &quot;&quot;;
                  txtproqty.Text = &quot;&quot;;
                  txtsubtotal.Text = &quot;0&quot;;
                  txtDiscountbill.Text = &quot;0&quot;;
                  txtgstper.Text = &quot;0&quot;;
                  txtgrandtotal.Text = &quot;0&quot;;
                  txtpaidamount.Text = &quot;0&quot;;
  
  
  
              }
              else
              {
                  //transaction failed
                  MessageBox.Show(&quot;Transaction completed failed to details table&quot;);
              }
  </code></pre>
  <p><strong>my data access layer is also as follows</strong></p>
  <pre><code>#region Insert Transaction MEthod
  
      public  bool  Insert_Transaction(transactionBLL t, out int transactionID)
      {
          bool issucess = false;
  
          transactionID = -1;
  
          SqlConnection connection = new SqlConnection(myconnstring);
  
  
          try
          {
              //sql query to insert transactions
           
              string sql = &quot;INSERT INTO tbl_transaction (type, date_cust_id, grandtotal, transaction_date, tax, discount, added_by) VALUES (@type, @date_cust_id, @grandtotal, @transaction_date, @tax, @discount, @added_by);SELECT @@IDENTITY;&quot;;
              SqlCommand cmd = new SqlCommand(sql, connection);
              cmd.Parameters.AddWithValue(&quot;@type&quot;, t.type);
              cmd.Parameters.AddWithValue(&quot;@date_cust_id&quot;, t.date_cust_id);
              cmd.Parameters.AddWithValue(&quot;@grandtotal&quot;, t.grandtotal);
              cmd.Parameters.AddWithValue(&quot;@transaction_date&quot;, t.transaction_date);
              cmd.Parameters.AddWithValue(&quot;@tax&quot;, t.tax);
              cmd.Parameters.AddWithValue(&quot;@discount&quot;, t.discount);
              cmd.Parameters.AddWithValue(&quot;added_by&quot;, t.added_by);
  
              connection.Open();
  
              object o = cmd.ExecuteScalar();
              
              //if the query is executed successfully then the value will not be null or vice versa
  
              if (o!=null)
              {
                  transactionID = int.Parse(o.ToString());
                  issucess = true;
                  
              }
              else
              {
                  issucess = false;
              }
              }
  
          catch (Exception ex)
          {
              MessageBox.Show(ex.Message);
          }
          finally
          {
              connection.Close();
          }
  
          return issucess;
      }
  
      #endregion
  </code></pre>
  <p><strong>Please find a way cause i cannot i am a person who does not have any coding backgroung tins is my first try by watching various youtube videos and tutorials i dont wanna be stuck due to my mistake</strong></p>