我使用的SqlDataSource显示根据登录的用户记录,必须声明标量变量“@ LoggedInUser”。错误尝试参数添加到SqlDataSource的
,并在页面加载我加入参数如下
protected void Page_Load(object sender, EventArgs e)
{
string user = HttpContext.Current.User.Identity.Name;
ModifyCustomerDataSource.SelectParameters.Clear();
ModifyCustomerDataSource.SelectParameters.Add("@LoggedInUser", user.Trim());
}
时但它给我错误
Must declare the scalar variable "@LoggedInUser".
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Must declare the scalar variable "@LoggedInUser".
有人可以指出我哪里出错了。 由于
这是使用sqldatasource的最佳实践吗?只是好奇。我正在解决不使用sqldatasource。如果你想要示例代码,请让我知道.. – AnandMohanAwasthi
@AnandMohanAwasthi,我绑定这个数据到我的jqGrid,所以这对我来说更简单了,好吧没有太多的想法是最好的做法,你可以问富好吧关于它。示例代码将帮助我。谢谢 – freebird