title: Visual Studio Database Not Updating
body: <p>I am working on a school project and for some reason my mysql database doesn't update despite no of row changed is more than 0 and triggering the Update sucessful alert. It also manage to only update my image data from my fileupload.</p>
  <pre><code>**admin_products_details_edit.aspx.cs**
  
  protected void btn_ProdEdit_Click(object sender, EventArgs e)
          {
              int result = 0;
              string image = &quot;&quot;;
  
              if (FileUpload_ProdImg.HasFile == true)
              {
                  image = &quot;images\\&quot; + FileUpload_ProdImg.FileName;
                  img_result.ImageUrl = FileUpload_ProdImg.FileName;
              }
              else 
              {
                  image = img_result.ImageUrl;
              }
              
              Product Prod = new Product();
              string datProdID = lbl_ProdID.Text;
              string datProdName = tb_ProdName.Text;
              string datProdDesc = tb_ProdDesc.Text;
              string datProdImg = img_result.ImageUrl;
              decimal datProdPrice = decimal.Parse(tb_ProdPrice.Text);
              int datProdCal = int.Parse(tb_ProdCal.Text);
              int datStockLvl = int.Parse(tb_StockLvl.Text);
              result = Prod.ProductUpdate(datProdID, datProdName, datProdDesc, datProdImg, datProdPrice, datProdCal, datStockLvl);
              if (result &gt; 0)
              {
                  string saveimg = Server.MapPath(&quot; &quot;) + &quot;\\&quot; + image;
                  FileUpload_ProdImg.SaveAs(saveimg);
                  Response.Write(&quot;&lt;script&gt;alert('Update successful');&lt;/script&gt;&quot;);
                  Response.Redirect(&quot;admin_products_details.aspx?ProdID=&quot; + datProdID);
  
              }
              else
              {
                  Response.Write(&quot;&lt;script&gt;alert('Update fail');&lt;/script&gt;&quot;);
              }
          }&lt;-The code for the button edit event trigger
  
  **Product.cs**
      ...public int ProductUpdate(string upID, string upName, string upDesc, string upImg, decimal upPrice, int upCal, int upstkLvl)
          {
              string queryStr = &quot;UPDATE Products SET&quot; + &quot; ProdName = @productName, &quot; + &quot; ProdDesc = @productDesc, &quot; + &quot; ProdImg = @productImage, &quot; + &quot; ProdPrice = @productPrice, &quot; + &quot; ProdCalorie = @productCal, &quot; + &quot; StockLevel = @productStkLvl &quot; + &quot; WHERE ProdID = @productID&quot;;
  
              SqlConnection conn = new SqlConnection(_connStr);
              SqlCommand cmd = new SqlCommand(queryStr, conn);
              cmd.Parameters.AddWithValue(&quot;@productID&quot;, upID);
              cmd.Parameters.AddWithValue(&quot;@productName&quot;, upName);
              cmd.Parameters.AddWithValue(&quot;@productDesc&quot;, upDesc);
              cmd.Parameters.AddWithValue(&quot;@productImage&quot;, upImg);
              cmd.Parameters.AddWithValue(&quot;@productPrice&quot;, upPrice);
              cmd.Parameters.AddWithValue(&quot;@productCal&quot;, upCal);
              cmd.Parameters.AddWithValue(&quot;@productStkLvl&quot;, upstkLvl);
  
              conn.Open();
  
              int nofRow = 0;
              nofRow = cmd.ExecuteNonQuery();
  
              conn.Close();
  
              return nofRow;
          }&lt;-The code for updating the mysql database,located in a different cs file,titled Product.cs
  </code></pre>
  <p>My mysql database table is called Products</p>
  <p>Thank you very much for your help in advance.</p>