为何button2_Click按钮(修改)执行不了;但是button1_Click(增加)按钮可以执行; 求具体怎么改 20

privatevoidForm1_Load(objectsender,EventArgse){SqlConnectioncon=newSqlConnection();co... private void Form1_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=.\\NEWSQL;DataBase=FastFood;Integrated Security=True";
SqlCommand com = new SqlCommand();
com.CommandText = "Select * from Customer";
com.Connection = con;
con.Open();
SqlDataReader dr = com.ExecuteReader();
bindingSource1.DataSource = dr;
dataGridView1.DataSource = bindingSource1;
dr.Close();
con.Close();
}

private void button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=.\\NEWSQL;DataBase=FastFood;Integrated Security=True";
SqlCommand com = new SqlCommand();
com.CommandText = "insert into Customer values('2010006','天鸳','***','海德堡','南京西路','16952364782','baihe@yahoo.com','爱哭')";
com.Connection = con;
con.Open();
com.ExecuteNonQuery();
con.Close();
}

private void button2_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=.\\NEWSQL;DataBase=FastFood;Integrated Security=True";
SqlCommand com = new SqlCommand();
com.CommandText = "update Customer set UserName='张伟' where CustomerID=2010007";
com.Connection = con;
con.Open();
com.ExecuteNonQuery();
con.Close();
}
展开
 我来答
匿名用户
2015-09-30
展开全部
加断点调试,输出sql语句,在sql中执行看看效果,确定是否数据库的相关表名等弄错了。
追问
具体怎么改;我是新手
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式