注册 登录
编程论坛 C# 论坛

“)”处有错???

紫小念 发布于 2013-12-14 16:49, 586 次点击
String s = "server=.;database=SampleDb;integrated Security=true;";
            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = s;
            SqlCommand com = new SqlCommand();
            String sql = String.Format("delete from Lesson  where Id='{0}' and  Name='{1}')",textBox1.Text,textBox2.Text);
            com.Connection = conn;
             = sql;
            conn.Open();
            int n = com.ExecuteNonQuery();

            conn.Close();
            MessageBox.Show("删除成功");
3 回复
#2
shangsharon2013-12-16 09:34
Name='{1}')"

这个')"是多余的
#3
ad78702013-12-19 18:33
回复 楼主 紫小念
你的是("delete from Lesson  where Id='{0}' and  Name='{1}')",textBox1.Text,textBox2.Text);
      ↑                                                 ↑                            ↑
                                                       这个多余
1