Link to home
Start Free TrialLog in
Avatar of jrram
jrramFlag for United States of America

asked on

How to create a VB6 / Oracle DNS-Less Connection (w/o tnsnames.ora file)

Hello all,

I'm trying to figure out how to construct a connection string to connect to an Oracle database w/o using the DNS and also w/o relying on an entry in the tnsnames.ora file.  

I tried the tutorial at (http://www.codeproject.com/KB/vbscript/connection_string.aspx), but it isn't working for me.

The error I am receiving is:

"Run-time error '-2147467259 (80004005)

[Microsoft][ODBC driver for Oracle][Oracle]ORA-12154: TNS could not resolve the connect identifier specified"

Below are the connection strings I've tried:

Attempt #1:
 
strCon = "Driver={Microsoft ODBC for Oracle}; " & _
         "CONNECTSTRING=(DESCRIPTION=" & _
         "(ADDRESS=(PROTOCOL=TCP)" & _
         "(HOST=QA01)(PORT=1521))" & _
         "(CONNECT_DATA=(SERVICE_NAME=TEST_DATABASE))); uid=read;pwd=read;"
 
Attempt #2:
 
strCon = "Driver={Microsoft ODBC for Oracle}; " & _
         "CONNECTSTRING=(DESCRIPTION=" & _
         "(ADDRESS=(PROTOCOL=TCP)" & _
         "(HOST=QA01)(PORT=1521))" & _
         "(CONNECT_DATA=((SID=QA01)(SERVICE_NAME=TEST_DATABASE)))); uid=read;pwd=read;"

Open in new window

Avatar of ajexpert
ajexpert
Flag of United States of America image

This link should help you
http://www.connectionstrings.com/oracle
 
Avatar of jrram

ASKER

A couple of other things that will hopefully help with a solution.  I am connection using an ADODB Connection.  I'm not sure if this matters.

Dim oCon: Set oCon = CreateObject("ADODB.Connection")
Dim oRs: Set oRs = CreateObject("ADODB.Recordset")
oCon.Open strCon

Database Port: 1521
Database SID: QA01
Database Name: TEST_DATABASE
Database Password: password

>> ajexpert,

The link that you suggested only had a connection w/o tnsnames.ora for VB.NET.  I am using VB6.
ASKER CERTIFIED SOLUTION
Avatar of ajexpert
ajexpert
Flag of United States of America 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
Avatar of jrram

ASKER

Do you know what the CID parameter stands for?
Here is what you can try:
Open a new VB project put a ADO Data Control on the form and configure its connection string by providing the details required by this.   Chose using connection string
After this u would get the required connection string which u can use in your Adodb connection