Forum Discussion

bommareddy's avatar
bommareddy
Contributor
8 years ago

Unable to connect to Oracle Database

Hi Team,

 

As a part of testing, I want to connect and retrieve the values from oracle database tables. So I am trying to connect Oracle DB using ADODB connections in the script. 

 

Function OracleDBvalues
Set con= CreateObject("ADODB.Connection") con.ConnectionString = "Provider=OraOLEDB.Oracle; User Id=userName;Password=password;Data Source=dataSourceName;Persist Security Info=True" con.Open query = "select * from tableName" Set RecSet = con.Execute(query) con.Close
End Function

I am facing the following error while running the above script.

 

ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA

 

Any pointers and suggestions are really appreciated. Also please let me know if you require any other details in this regard.

 

Regards, BommaReddy

1 Reply

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    A quick Google search found a number of hits that note that, depending upon your version of Oracle, you might need to provide a service name in your connection string. For that matter, there are some connection string differences as well for these different Oracle versions.

    I'm no Oracle person... I don't know beans about what to put in the connection string to fix this... but www.connectionstrings.com has a number of formats... check out this one

    https://www.connectionstrings.com/oracle-in-orahome92/

     

    This might not fix your problem because it is dependent upon a particular installation of Oracle but, in short, your problem is in your connection string... fix that, and you're golden.