Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dsn Connection To Call Sproc

Status
Not open for further replies.

evaleah

Programmer
Mar 18, 2003
252
US
I have a call to an Oracle stored procedure. I have two linked tables from the same Oracle DB as I would like to execute the stored procedure from. Ideally, I would like to use the DSN I am using to link the tables to also access the stored procedure so I am only maintaining the link in one place. I have attempted to use the following:
Code:
Private Function GetQuestionResult(ByVal ShortName As String, ByVal SiteID As Integer) As Integer
    Dim db As DAO.Database
    Dim LSProc As DAO.QueryDef
    Dim LRst As DAO.Recordset
    Dim LSQL As String
    
    On Error GoTo Err_Execute
    
    Set db = CurrentDb()
    Set LSProc = db.CreateQueryDef("")
    
    'SQL to call stored procedure (with parameters)
    LSQL = "BEGIN VALIDATIONQUESTIONRESULT (""" & ShortName & """, " & SiteID & "); END;"
    
    'Use DSN ODBC connection
    LSProc.Connect = "ODBC;DSN=OUTPATIENT;"
    LSProc.SQL = LSQL
    LSProc.ReturnsRecords = True
    
    Set LRst = LSProc.OpenRecordset
    GetQuestionResult = LRst.Fields(0).Value
    
    Set LSProc = Nothing
    
    Exit Function
    
Err_Execute:
    MsgBox "The call to the Oracle stored procedure failed."
    Set LSProc = Nothing
End Function
But I keep getting an "ODBC--Call failed" error. The DSN with that name is working for the linked tables, just not here. I have tried putting the uid and pwd in, but I get the same result. Can anyone help me figure out what I am doing wrong?

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top