Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 334
  • Last Modified:

PL/SQL - VB.net - Would like to return back to vb.net a number value from pl/sql.

I need to call a stored procedure that has some updates and inserts and that returns a number. I have written succesfully a method to return a cursor but into a datatable but i can not make it to return a single number.


        Public Sub exec_ora_proc_number(ByVal cmd As OracleCommand)
            Dim strSQL As String = Me.SQLString
            If (Me.SQLString.IndexOf(".") = -1) Then
                strSQL = "admin." + strSQL
            End If
            cmd.Connection = DBConnection.ConnectionObject
            cmd.CommandText = strSQL
            cmd.CommandType = CommandType.StoredProcedure
            cmd.Parameters.Add(New OracleParameter("p_numberout", OracleType.Number)).Direction = ParameterDirection.Output
            '-- Execute the command
            Try
                Dim MyDA As New OracleDataAdapter(cmd)
                'MyDA.Fill(myDS, mvarTableName)
                'MyDA.Fill(Me.mvarDS, mvarTableName)
            Catch I As OracleException
            Catch x As Exception
                MessageBox.Show(x.Message.ToString)
            End Try
        End Sub
0
spiral2007
Asked:
spiral2007
1 Solution
 
CodeCruiserCommented:
Try following code


Public Sub exec_ora_proc_number(ByVal cmd As OracleCommand)
            Dim strSQL As String = Me.SQLString
            If (Me.SQLString.IndexOf(".") = -1) Then
                strSQL = "admin." + strSQL
            End If
            cmd.Connection = DBConnection.ConnectionObject
            cmd.CommandText = strSQL
            cmd.CommandType = CommandType.StoredProcedure
            cmd.Parameters.Add(New OracleParameter("p_numberout", OracleType.Number)).Direction = ParameterDirection.Output
            '-- Execute the command
            Try
                cmd.ExecuteNonQuery()
                msgbox cmd.Parameters(0).Value
            Catch I As OracleException
            Catch x As Exception
                MessageBox.Show(x.Message.ToString)
            End Try
        End Sub

Open in new window

0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now