Link to home
Start Free TrialLog in
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()
Avatar of craskin
craskin
Flag of United States of America image

try
CMD.Command = "TEST"
CMD.CommandType = CommandType.StoredProcedure
Avatar of ewang1205
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
Avatar of BooMod
BooMod
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial