转换nvarchar时,Asp QueryStringParameter转换失败

时间:2015-04-19 14:43:37

标签: c# asp.net parameters querystringparameter

当我运行以下代码时,我得到这个错误,全局s是静态int,我看了很多文章,但看不出这出错的地方:

  

异常详细信息:System.Data.SqlClient.SqlException:Conversion   将nvarchar值'glb.catID'转换为数据类型时失败   中间体

<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

0 个答案:

没有答案