【问题标题】:asp.net gridview using parameter query to as400as400使用参数查询asp.net gridview
【发布时间】:2010-09-25 04:25:39
【问题描述】:

我正在尝试通过将值传递给存储在会话变量中的数据(从文本框收集)中的参数,将 as400 数据检索到网格视图中。如果我硬连线查询选择,它工作正常,但尝试传递参数会给出错误:SQL0206: Column @myParm not in specified tables。

使用 SQL Server 中的表时,我没有收到此错误。这可能吗,还是我应该采取另一种方法?任何建议表示赞赏。

<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>

【问题讨论】:

    标签: gridview sqldatasource ibm-midrange


    【解决方案1】:

    我不确定您如何连接到 AS400,但我认为 IBM ODBC 驱动程序不支持命名参数。您必须改为输入?,并以正确的顺序传递参数。

    【讨论】:

    • 非常感谢!这 ?成功了。顺便说一句,我正在使用 OleDBConnection
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-03
    • 2022-10-13
    • 1970-01-01
    相关资源
    最近更新 更多