我使用的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