Results 1 to 4 of 4

Thread: Calling Oracle stored procedure from MS Access

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    12

    Calling Oracle stored procedure from MS Access

    I am trying to execute a stored procedure which accepts an input parameter and returns a resultset using ref cursor, from an MS Access forrm using the below connection string:

    Public conn1= "Driver={Microsoft ODBC for Oracle};CONNECTSTRING=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=myserver.com)(PORT=1000))(CONNECT_DA TA=(SID=xe))); uid=mylogin;pwd=pwd;"

    Below is the generic function in the VBA code which will accept a sql string (can be with one or more or even without any parameters).

    ' without parameter
    strsql="CallMyProc"

    'with parameter
    'strsql="CallMyProc('name')"


    public function call OracProc(strsql)

    Dim db As ADODB.Connection
    Dim cmd As ADODB.Command
    Dim rs As ADODB.Recordset

    Set db = New ADODB.Connection
    db.ConnectionString = conn1
    db.Open

    Set cmd = New ADODB.Command


    With cmd
    Set .ActiveConnection = db
    'cmd.Properties("PLSQLRSet") = True
    .CommandType = adCmdStoredProc
    .CommandText = strsql
    Set rs = cmd.Execute()

    End With

    If Not IsObject(rs) Then

    rs.MoveFirst
    OracProc= Trim(rs.Fields(0))

    End If


    end function

    The above code does not work. Its giving an error.

    Can someone please provide a correct solution?

    i do not want to use create parameter as the function in the VBA code will be generic
    Last edited by acpt; Oct 31st, 2014 at 01:36 PM. Reason: correction

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Calling Oracle function from MS Access

    I don't see how Access plays into this. I don't see any place where you connected to Access... are you saying that you're running this from inside an Access database? Or is this from VB6 code?

    The above function does not work. Its giving an error.
    Well, that's nice. I can only guess that the error has something to do with eels. Your best bet would be to remove the eels from your hovercraft. There is a guide in my signature that explains how to get rid of those pesky eels.


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    New Member
    Join Date
    Apr 2006
    Posts
    12

    Re: Calling Oracle function from MS Access

    Quote Originally Posted by techgnome View Post
    I don't see how Access plays into this. I don't see any place where you connected to Access... are you saying that you're running this from inside an Access database? Or is this from VB6 code?


    Well, that's nice. I can only guess that the error has something to do with eels. Your best bet would be to remove the eels from your hovercraft. There is a guide in my signature that explains how to get rid of those pesky eels.


    -tg
    made corrections to my post. Please read again

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Calling Oracle function from MS Access

    Quote Originally Posted by acpt View Post
    made corrections to my post. Please read again
    I'm not going to make corrections to my post, but rather I'll just repeat myself.

    The above function does not work. Its giving an error.
    Well, that's nice. I can only guess that the error has something to do with eels. Your best bet would be to remove the eels from your hovercraft. There is a guide in my signature that explains how to get rid of those pesky eels.


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width