当我运行以下代码时出现此错误,全局 s 是静态 int,我查看了很多文章,但看不到哪里出了问题:
异常详细信息:System.Data.SqlClient.SqlException:将 nvarchar 值“glb.catID”转换为数据类型 int 时转换失败。
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:CommerceConnectionString %>"
SelectCommand="select CategoryID, CategoryName, ProductImage, Title, SubCatID
from Categories
JOIN Products
ON Categories.CategoryID= Products.CatID
WHERE CategoryID = @CategoryID AND SubCatID = @SubCatID ">
<SelectParameters>
<asp:QueryStringParameter Name="CategoryID" QueryStringField="CategoryID" DefaultValue="glb.catID" />
<asp:QueryStringParameter Name="SubCatID" QueryStringField="SubCatID" DefaultValue="glb.subcatID"/>
</SelectParameter