views:

47

answers:

1

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>
+1  A: 

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.

GôTô
Many thanks! The ? did the trick. BTW, am using OleDBConnection