.net使用GridView控件删除时提示必须声明标量变量“@什么什么”,该如何解决?
stringsql="deletefrom[User]whereUsreId=@UsreId";SqlCommandcmm=newSqlCommand(sql,conne...
string sql = "delete from[User] where UsreId=@UsreId";
SqlCommand cmm = new SqlCommand(sql, connection);
Int32 userId = Convert.ToInt32(this.GridView1.DataKeys[e.RowIndex].Value);
cmm.Parameters.Add(new SqlParameter("@UserId", userId));
cmm.ExecuteNonQuery();
connection.Close();
this.Response.Redirect("MultilineUserQuery.aspx");
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
onrowdeleting="GridView1_RowDeleting" DataKeyNames="UserId" >。
必须声明标量变量“@UserId” 展开
SqlCommand cmm = new SqlCommand(sql, connection);
Int32 userId = Convert.ToInt32(this.GridView1.DataKeys[e.RowIndex].Value);
cmm.Parameters.Add(new SqlParameter("@UserId", userId));
cmm.ExecuteNonQuery();
connection.Close();
this.Response.Redirect("MultilineUserQuery.aspx");
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
onrowdeleting="GridView1_RowDeleting" DataKeyNames="UserId" >。
必须声明标量变量“@UserId” 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询