无法从直接调用数据库的代码中调用存储过程
我使用 RazorSQL 连接到 Informix 服务器,创建了一个存储过程并对其进行了测试,得到了预期的答案,因此该过程以某种形式存在于数据库中。
然后,我运行以下代码:
If ConnectToInformix() Then
Dim cmd As New IfxCommand("dc_routeHasOutstandingQuantity", conn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add(New IfxParameter("WorksOrder", wo_num))
cmd.Parameters.Add(New IfxParameter("CompNo", IBM.Data.Informix.IfxType.SmallInt)).Value = CType(compNo, Int16)
rdr = cmd.ExecuteReader
为了完整起见,这里是 ConnectToInformix 函数。
Private Function ConnectToInformix() As Boolean
Try
If conn Is Nothing Then
conn = New IfxConnection
conn.ConnectionString = ConnectionString
End If
If conn.State = System.Data.ConnectionState.Closed Then
conn.Open()
End If
Return True
Catch ex As System.Exception
conn.Dispose()
conn = Nothing
Return False
End Try
End Function
ConnectToInformix 函数对于该程序建立的每个其他 Informix 连接都可以正常工作,但这是使用的第一个 Informix 存储过程,所以也许有一些特殊的魔法我必须在连接上工作......
无论如何,当我尝试调用在 rdr = cmd.ExecuteReader
行上的存储过程中,我收到以下错误:
ERROR [HY000] [Informix .NET provider][Informix]Cannot read system catalog (sysprocedures).
从实时 SQL 连接调用存储过程时,不会发生此错误。
我做错了什么?
I connected to the Informix server using RazorSQL, created a stored procedure and tested it, getting the expected answer, so the procedure exists in the database in some form.
I then run the following code:
If ConnectToInformix() Then
Dim cmd As New IfxCommand("dc_routeHasOutstandingQuantity", conn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add(New IfxParameter("WorksOrder", wo_num))
cmd.Parameters.Add(New IfxParameter("CompNo", IBM.Data.Informix.IfxType.SmallInt)).Value = CType(compNo, Int16)
rdr = cmd.ExecuteReader
For completeness' sake, here is the ConnectToInformix function.
Private Function ConnectToInformix() As Boolean
Try
If conn Is Nothing Then
conn = New IfxConnection
conn.ConnectionString = ConnectionString
End If
If conn.State = System.Data.ConnectionState.Closed Then
conn.Open()
End If
Return True
Catch ex As System.Exception
conn.Dispose()
conn = Nothing
Return False
End Try
End Function
The ConnectToInformix function works fine for every other Informix connection made by this program, but this is the first Informix stored procedure being used, so maybe there's some special magic I have to work on the connection...
Anyway, when I try to call the stored procedure on the rdr = cmd.ExecuteReader
line I get the following error:
ERROR [HY000] [Informix .NET provider][Informix]Cannot read system catalog (sysprocedures).
This error does not occur when calling the stored procedure from a live SQL connection.
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我要检查的第一件事是您的用户是否拥有数据库和存储过程的权限。
First thing I'd check is you’re user has permissions to the database, and to that stored procedure.