Invalid connection string from Access to Oracle

Posted on 2008-11-05
Last Modified: 2012-05-05
Hello everyone,

I have a Sub in Access, which I want it to be a DSN-less connection, and execute a pass-through query. But gives me an error: Invalid Connection String in pass-through query.

I'd appreciate any comments or suggestions

Sub passthrough_query_test()

    Dim dbs As Database

    Dim qdfPassThrough As QueryDef

    Dim qdfTemp As QueryDef

    Set dbs = CurrentDb()

    Set qdfPassThrough = dbs.CreateQueryDef("consultaOrden")

    qdfPassThrough.Connect = ("Driver={Microsoft ODBC for Oracle};;Uid=stsag;Pwd=prod666;")


    qdfPassThrough.SQL = "SELECT num_orden from AG_ORDENES where num_orden=1092385"

    qdfPassThrough.ReturnsRecords = True

    With dbs

    Set qdfTemp = .CreateQueryDef("tablaTmp", "SELECT * from consultaOrden")

    DoCmd.OpenQuery "tablaTmp"

    .QueryDefs.Delete "tablaTmp"

    End With

    dbs.QueryDefs.Delete "consultaOrden"


    End Sub

Open in new window

Question by:Ivette_Diaz
    LVL 18

    Assisted Solution

    Check out to validate your connect string.

    Author Comment

    Thank you, now it's valid but gives me the folowwing error:

    "Driver's SQLSetConnectAttr failed"

    I changed my connection string to:

    oConn.Open "Driver={Microsoft ODBC for Oracle};" & _
               "Dbq=REPOGARA" & _
               "Uid=pepe;" & _
    LVL 18

    Accepted Solution

    The problem is most likely that the ODBC settings expect Oracle 8.0 to be used by default. So change the registry to look for Oracle 9 DLLs and DSN creation succeeds.

    Need to change 2 registry entries, see HKLMSoftwareMicrosoftMSDTCMTxOCI
    and change OracleXaLib from oraclient8.dll to oraclient9.dll and change OracleSqlLib from orasql8.dll to orasql9.dll (note: if OracleOciLib is oci.dll do not change it).

    (As a reference see outdated Microsoft article Q264012).


    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now