PDA

Click to See Complete Forum and Search --> : Connect to Oracle Database


ipmurali
Jan 9th, 2000, 03:55 AM
I tried the single line connection code like this
cn.Open "Provider=MSDAORA.1;Data Source=Personal Oracle7;User Id=SCOTT;Password=TIGER;"
but am getting error message like this
"Runtime error - 2147467259(80004005)
ORA-12154-TNS:Could not resolve service name"
I am using Personal Oracle 7.3.4
I think the error is in Data Source string
Please help me
thanks

[This message has been edited by ipmurali (edited 01-11-2000).]

gnosys
Jan 10th, 2000, 02:30 AM
This should work. Go into Oracle's SQL Net Easy Configuration utility and create an Alias for the Oracle Service you want to connect to. For example, you create an Alias named 'ThisAlias', using the 'named pipes' protocol, and you enter the Oracle server's name and the database instance. Now you can go into the ODBC administrator in Control Panel and create a DSN for Oracle. Choose the Oracle73 driver, then give the DSN a name and a description. Where it asks you for 'SQL Net Connect String', enter the name of the alias ('ThisAlias') that you created in the previous step. You can test the new DSN using the '32-bit ODBC TEST' utility. Assuming it works, now you can connect to the Oracle DB through ADO using a connect string of "DSN=ThisAlias, UID=sa, PWD=pwd;"

Clunietp
Jan 10th, 2000, 10:52 AM
Or you can use a one line connection string here

Add reference to Microsoft ActiveX Data Objects 2.x Libarary (x = 0 or 1)


Dim rs As Recordset
Dim cn As Connection
Set cn = New Connection


cn.Open "Provider=MSDAORA.1;Data Source=ServerName;User Id=stocks;Password=stocks;"


Set rs = cn.Execute("Select * from MyTable")


Do Until rs.EOF = True
Debug.Print rs.Fields(0).Value
rs.MoveNext
Loop