System.Data.SqlClient.SqlException: '(' 附近有语法错误。 10
protectedvoidDataList1_ItemCommand(objectsource,DataListCommandEventArgse){if(e.Comma...
protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
if (e.CommandName == "addshop")
{
//商品id
string id = DataList1.DataKeys[e.Item.ItemIndex].ToString();
string username = "nihao";
int goodid = Convert.ToInt32(id);
//购买者
String strconn;
strconn = "Server=ZEE-PC;DataBase=sb;Uid=sa;pwd='123456'";
SqlConnection conn=new SqlConnection(strconn);
conn.Open();
string sqlstr = "insert into carts (username,goodid) values('" + username + "'," + goodid + ")";
SqlCommand scmd = new SqlCommand(sqlstr, conn);
scmd.ExecuteNonQuery();
//Response.Write("id");
}
}
protected void DataList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
} 展开
{
if (e.CommandName == "addshop")
{
//商品id
string id = DataList1.DataKeys[e.Item.ItemIndex].ToString();
string username = "nihao";
int goodid = Convert.ToInt32(id);
//购买者
String strconn;
strconn = "Server=ZEE-PC;DataBase=sb;Uid=sa;pwd='123456'";
SqlConnection conn=new SqlConnection(strconn);
conn.Open();
string sqlstr = "insert into carts (username,goodid) values('" + username + "'," + goodid + ")";
SqlCommand scmd = new SqlCommand(sqlstr, conn);
scmd.ExecuteNonQuery();
//Response.Write("id");
}
}
protected void DataList1_SelectedIndexChanged(object sender, EventArgs e)
{
}
} 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询