protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName == "Edit1")
        {
            int idd = Convert.ToInt32(e.CommandArgument.ToString());
            Label str1 = (Label)e.Item.FindControl("ballotLabel");
            int xx = Convert.ToInt32(str1.Text) + 1;
            SqlConnection sqlconn = new SqlConnection(ConfigurationManager.ConnectionStrings["tt-bikeConn"].ConnectionString);
            sqlconn.Open();
            string constr = "Update [activityentry] Set(ballot='" + xx + "') where id='" +idd + "'";
            SqlCommand sc = new SqlCommand(constr, sqlconn);
            sc.ExecuteNonQuery();//出错了这里  请问怎么回事
            str1.Text = xx.ToString();
            Response.Write("<script>alert('" + e.CommandArgument.ToString() + "')</script>");
        }
在线等  急   谢谢

解决方案 »

  1.   

    string constr = "Update [activityentry] Set(ballot='" + xx + "') where id='" +idd + "'";
    应该是这边有问题吧
    set后面跟个空格就可以了,不用再加括号了吧
      

  2.   

    与数据库的操作都要加个try{}catch{}然后你Debug调试下, 看他出什么异常, 或者你看下你的sql语句, 去数据库执行下, 就知道什么原因了。 。
      

  3.   

    string constr = "Update [activityentry] Set ballot='" + xx + "' where id='" +idd + "'";
    查询分析器执行
      

  4.   

     string constr = "Update [activityentry] Set(ballot='" + xx + "') where id='" +idd + "'";xx在上面是INT类型的,你直接加到string 里面去,难道这个位置没有报错吗?
      

  5.   

    我来了,解决方案:
    string constr = "Update [activityentry] Set ballot='" + xx + "'  where id='" +idd + "'";