注册 登录
编程论坛 ASP.NET技术论坛

求救啊~!!!!

cinderella0 发布于 2008-09-27 15:43, 744 次点击
我的代码那错了啊。。。。。
       CollectSelected();

        this.TextBox6.Text = string.Empty;
        foreach (object tmp in this.SelectedItems)
            this.TextBox6.Text += tmp.ToString() + ",";
        string a = this.TextBox6.Text;        
        a = a.TrimEnd(',');
        SqlConnection con = new SqlConnection("server=localhost;database=User;user=grid;password=grid");
        con.Open();
        SqlCommand com = new SqlCommand("(update Message set huiyuanjiezhishijian='" + this.Text1.Value + "' where ID in('" + a +"'))", con);
        SqlDataAdapter da = new SqlDataAdapter(com);
        DataSet ds = new DataSet();
        Response.Write(a+"-----------------");
        con.Close();
为什么数据没有更新啊。。。。。。。
5 回复
#2
kevintang2008-09-27 15:57
CollectSelected();

        this.TextBox6.Text = string.Empty;
        foreach (object tmp in this.SelectedItems)
            this.TextBox6.Text += tmp.ToString() + ",";
        string a = this.TextBox6.Text;        
        a = a.TrimEnd(',');
        SqlConnection con = new SqlConnection("server=localhost;database=User;user=grid;password=grid");
        con.Open();
        SqlCommand com = new SqlCommand("update Message set huiyuanjiezhishijian='" + this.Text1.Value + "' where ID ='" + a +"'", con);
        SqlDataAdapter da = new SqlDataAdapter(com);
        DataSet ds = new DataSet();
        Response.Write(a+"-----------------");
        con.Close();
#3
cinderella02008-09-27 16:09
不行啊,还是不行。。。。。。。。数据更新不进去。。。。。。。。
#4
cinderella02008-09-27 16:10
我的ID是字符串。不能那么写的,只能用where id in()这个形式。。。。
#5
bygg2008-09-27 17:16
把语句输出来到数据库中去执行一下看可以不
#6
仰望星空2008-09-27 21:14
SqlCommand com = new SqlCommand("update Message set huiyuanjiezhishijian='" + this.Text1.Value + "' where ID ='" + a +"'", con);
完了呢?
com不需要再调用个ExecuteNonQuery()方法执行一下吗?


SqlDataAdapter da = new SqlDataAdapter(com);
DataSet ds = new DataSet();
这两句做什么的?好像没用吧
1