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>");
}
在线等 急 谢谢
{
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>");
}
在线等 急 谢谢
应该是这边有问题吧
set后面跟个空格就可以了,不用再加括号了吧
查询分析器执行
string constr = "Update [activityentry] Set ballot='" + xx + "' where id='" +idd + "'";