asp.net gridview使用参数查询到as400
我试图通过将存储在会话变量中的数据(从文本框收集)的值传递给参数来将 as400 数据检索到 gridview 中。如果我硬连线查询选择,它工作正常,但尝试传递参数会出现错误:SQL0206:列@myParm不在指定表中。
使用 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>
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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定您如何连接到 AS400,但我认为 IBM ODBC 驱动程序不支持命名参数。您必须改为放置
?
,并按正确的顺序传递参数。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.