String st = "Insert into info values(@first,@second)";
SqlCommand cmd = new SqlCommand(st, con);
cmd.Parameters.AddWithValue("@first", TextBox1.Text);
cmd.Parameters.AddWithValue("@second", TextBox2.Text);
SqlCommand myCom=new SqlCommand(st,con);
int numrow=myCom.ExecuteNonQuery(); //replace con with myCom
con.Close();
If you feel helped. Please mark this post as Answer
tdmca
Contributor
2396 Points
661 Posts
Re: ExecuteNonQuery error
Apr 06, 2012 04:12 PM|LINK
String st = "Insert into info values(@first,@second)";
SqlCommand cmd = new SqlCommand(st, con);
cmd.Parameters.AddWithValue("@first", TextBox1.Text);
cmd.Parameters.AddWithValue("@second", TextBox2.Text);
SqlCommand myCom=new SqlCommand(st,con);
int numrow=myCom.ExecuteNonQuery(); //replace con with myCom
con.Close();