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

继续求救啊。。。。。。。。。

cinderella0 发布于 2008-09-27 16:17, 626 次点击
谁能帮我看看,我的代码那错了,,,,为什么不能执行更新语句啊。。。。。
 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+"-----------------");
        Response.Write("update Message set huiyuanjiezhishijian='" + this.Text1.Value + "' where ID in(" + a +")"  + "-----------------");
        con.Close();
2 回复
#2
zjc_KK2008-09-28 07:05
路过!
不知道你的意图是啥,如果只是希望更新到数据库的话,直接用com.ExecuteNonQuery();替换
     SqlDataAdapter da = new SqlDataAdapter(com);
        DataSet ds = new DataSet();
这两句就可以了.
     如果你想用SqlDataAdapter 更新的话,你的DataSet是空的,也没看见调用SqlDataAdapter的Update()方法,应该不会更新数据库吧~~~~~~
#3
kevintang2008-09-28 08:43
我日啊!原来是你啊!
   你在群里问过了啊!
   你做JSP 的!
   做.NET的话  你应该把 去看看啊!
1