2) if your sal field is numeric then dont use single quotes for that field
SqlCommand cmd
=newSqlCommand("update emp set name='"+TextBox1.Text+"',desg='"+TextBox2.Text+"',sal = "+TextBox3.Text+",city='"+TextBox4.Text+"',email='"+TextBox5.Text+"' where id ="+ id, con);
3) use the textboxes as txtname for name, txtdesg for desg , txtsal for sal , txtcity for city , txtemail for email
tusharrs
Contributor
3230 Points
668 Posts
Re: How to update GridView?
Apr 23, 2012 11:50 AM|LINK
Hi,
1) check the connection string
2) if your sal field is numeric then dont use single quotes for that field
SqlCommand cmd = new SqlCommand("update emp set name='" + TextBox1.Text + "',desg='" + TextBox2.Text + "',sal = " + TextBox3.Text + ",city='" + TextBox4.Text + "',email='" + TextBox5.Text + "' where id =" + id, con);
3) use the textboxes as txtname for name, txtdesg for desg , txtsal for sal , txtcity for city , txtemail for email
( Mark as Answer if it helps you out )
View my Blog