try
{
if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "")
{
MessageBox.Show("有选项是空的,回去看清楚了再来");
return;
}
using (SqlConnection con = new SqlConnection("Server=CROW\\EXAMPLE;uid=sa;pwd=0501;database=db_test01")) //确保及时释放资源
{
con.Open();
string strselect = "select COUNT(*) from Table_1 where ID = '" + textBox1.Text + "'";
SqlCommand cmd = new SqlCommand(strselect, con);
//查询编号是否有效
int intconut = Convert.ToInt32(cmd.ExecuteScalar().ToString());
//编号有效 进行修改数据
if (intconut != 0)
{
string sqlins = "updata Table_1 set NAME= '" + textBox2.Text + "',SEX= '" + textBox3.Text + "'where ID= '" + textBox1.Text + "'";
//创建command对象
SqlCommand cmd1 = new SqlCommand();
//设置sql语句
cmd1.CommandText = sqlins;
//调用打开数据库的方法
cmd1.Connection = con;
//执行添加数据
cmd1.ExecuteNonQuery();
MessageBox.Show("修改数据成功");
fillDataview();
}
else
{
MessageBox.Show("编号输入错误,回去看清楚再来");
}
}
}
catch (Exception ee)
{
MessageBox.Show(ee.Message.ToString());
textBox5.Text = (ee.Message.ToString());
}
}
帮我看下 怎么老提示'=' 附近有语法错误。
成功追40分