Hi!
i want to update my database table on button click event. here is the query.
protected void Button4_Click(object sender, EventArgs e)
{
con.Open();
SqlCommand cmd = new SqlCommand("update Arrear set ConsumerNo=" + ConsumerNo.Text + ",WaterCharges='" + WaterCharges.Text + "',SaverageCharges='" + SaverageCharges.Text + "',ConservancyCharges='" + SaverageCharges.Text + "',arear='" + arear.Text + "' where ConsumerNo=" + ConsumerNo.Text, con);
con.Close();
}
but it does not update the table. please tell me what is the problem
Loading
Mayur GujrathiPosted Jun 2, 2011, 2:21 AM
Mayur GujrathiPosted Jun 2, 2011, 6:09 AM
Posted Jun 2, 2011, 2:03 AM
Suthish NairPosted Jun 2, 2011, 1:59 AM
You must use Parameterized Queries..
Refer articles..
Parameterized Query and SQL Injection Attacks
Link
saifullah khanPosted Jun 2, 2011, 1:58 AM
secondly i am using sql 2008R2. i tried alot but not found the sql profiler. could you please tell me where it is???
Posted Jun 2, 2011, 1:46 AM
The best way , start the sql profiler/ just copy the cmd text (while debuggin), and paste it in sql query window and see why it is not updating...
The reason could the where clause value (consumerNo) also.