开发者

asp.net gridview using parameter query to as400

I'm trying to retrieve as400 data into a gridview by passing a value to a parameter from data stored in a session variable, gathered from a text box. If I hardwire the query selection, it works fine, but trying to pass the parmameter gives the error: SQL0206: Column @myParm not in specified tables.

I don't get this error when using tables from SQL Server. Is this possible to do, or should I take another approach? Any suggestions are appreciated.

<asp:SqlDataSource ID="SqlAS400" runat=开发者_如何学编程"server" 
    ConnectionString="<%$ ConnectionStrings:conAS400 %>" 
    ProviderName="<%$ ConnectionStrings:conAS400.ProviderName %>" 

 SelectCommand="SELECT field1, field2 FROM MYLIB.MYFILE WHERE field1 = 'ABC'"> works fine

 SelectCommand="SELECT field1, field2 FROM MYLIB.MYFILE WHERE field1 = @myParm "> fails

   <SelectParameters>
    <asp:SessionParameter Name="myParm" SessionField="gMyParm" Type="String" />
   </SelectParameters>

</asp:SqlDataSource>


I am not sure how you connect to your AS400, but I think the IBM ODBC driver does not support named parameters. You have to put ? instead, and pass the parameters in the right order.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜