我正在尝试从代码隐藏中显示 sql 选择结果,但是发生了此错误:
必须声明标量变量“@poNum”。
第 75 行:sdsUsers.SelectParameters.Add("@poNum", poNum.Text.Trim());
第 76 行:
第 77 行:DataView dvMember = (DataView)sdsUsers.Select(DataSourceSelectArguments.Empty); //这里的错误
第 78 行:DataTable tblMember = dvMember.Table;
代码:
string connectionString2 = ConfigurationManager.ConnectionStrings["WholesaleConnectionString"].ConnectionString;
string selectSql = "SELECT invoiceNum, poNum FROM SendInvoice where poNum = @poNum";
SqlDataSource sdsUsers = new SqlDataSource(connectionString2, selectSql);
sdsUsers.SelectParameters.Clear();
sdsUsers.SelectParameters.Add("@poNum", poNum.Text.Trim());
DataView dvMember = (DataView)sdsUsers.Select(DataSourceSelectArguments.Empty); //error occured here
DataTable tblMember = dvMember.Table;
for(int i=0;i<tblMember.Rows.Count;i++) {
if (i==0){
Label aaa = new Label();
aaa.Text = tblMember.Rows[i].ItemArray[0].ToString();
}
}
我被这个问题困扰了好几天,我找不到解决方案