Avatar of ewang1205
ewang1205
 asked on

execute a Oracle stored procedure

I have the following code the execute a procedure called test.   I says invalid SQL.  I know if I use SELECT this will work. What's wrong here?   Thanks.
 
       Dim conn = New OracleConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString"))
        Dim CMD = New OracleCommand

        CMD.Connection = conn
        CMD.CommandText = "EXECUTE TEST"

        conn.Open()
        Dim ct As Integer = CInt(CMD.ExecuteScalar())

        conn.Close()
ASP.NET

Avatar of undefined
Last Comment
BooMod

8/22/2022 - Mon
craskin

try
CMD.Command = "TEST"
CMD.CommandType = CommandType.StoredProcedure
ewang1205

ASKER
The ExecuteScalar() probably won't work.  I switched to dataset and data adapter and working now.  Here is the workin code.


Imports System.Data
Imports System.Data.OracleClient
Imports System.Data.SqlClient

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Dim conn = New OracleConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionString"))
        Dim CMD = New OracleCommand
        Dim da = New OracleClient.OracleDataAdapter(CMD)
        Dim ds = New DataSet

        CMD.Connection = conn
        conn.Open()

        CMD.CommandTEXT = "TEST"

        CMD.CommandType = CommandType.StoredProcedure

        da.SelectCommand = CMD
        da.Fill(ds, "ContactRequests")

        conn.Close()

    End Sub
End Class

ASKER CERTIFIED SOLUTION
BooMod

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy