无法从直接调用数据库的代码中调用存储过程

发布于 2024-11-07 21:18:36 字数 1349 浏览 0 评论 0原文

我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妖妓 2024-11-14 21:18:36

我要检查的第一件事是您的用户是否拥有数据库和存储过程的权限。

First thing I'd check is you’re user has permissions to the database, and to that stored procedure.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文