I have one table Metal_Master in that column having Opening_Weight I am updating value of that column by fetching previous value and aadding some value then again update that value .
My code for this is
ConnectionDB ReturnMWeight = new ConnectionDB("SELECT Opening_Weight FROM Metal_Master WHERE Metal_Name='GOLD';");
DataTable weighttd = ReturnMWeight.returntable();
GoldW = GoldW + Convert.ToDouble(weighttd.Rows[0][0].ToString());
ConnectionDB AddMWeight = new ConnectionDB("UPDATE Metal_Master SET Opening_Weight=" + GoldW + " WHERE Metal_Name='GOLD';");
AddMWeight.AddData();
But i want to directly update value in single query Please help ..
you can do the
UPDATEdirectly without running select statement,for better quality of code,
usingstatement for proper objet disposaltry-catchfor proper handling of unexpected exceptions.sql injection