Invalid connection string from Access to Oracle

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

Regards
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};Server=OracleServer.world;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"
    dbs.Close
 
    End Sub

Open in new window

Ivette_DiazAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jmoss111Commented:
Check out www.connectionstrings.com to validate your connect string.
Ivette_DiazAuthor Commented:
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;" & _
           "Pwd=anyone"
jmoss111Commented:
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).

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.