0

I set up an ODBC connection using ODBC Data Source Administrator . I have named it "BIOTPL" connect like this:

enter image description here

The corresponding code is :

Set Conn = Server.Createobject("ADODB.Connection")  
Conn.Open "Provider=OraOLEDB.Oracle;Data Source=simple_dsn;User Id=USER;Password=PASSWORD;"

But I am getting this error .

ORA-12154: TNS:could not resolve the connect identifier specified

How can I solve this error ? Please help me .

Christopher Marlowe
  • 2,098
  • 6
  • 38
  • 68
  • 3
    Possible duplicate of [Oracle ORA-12154: TNS: Could not resolve service name Error?](http://stackoverflow.com/questions/206055/oracle-ora-12154-tns-could-not-resolve-service-name-error) – paulsm4 Feb 05 '17 at 06:22
  • 1
    I hope the password details in that connection string are just made up or you've just exposed your server creds to the internet. – user692942 Feb 05 '17 at 13:42
  • Thanks @Lankymart for making me alerted . – Christopher Marlowe Feb 06 '17 at 03:54

3 Answers3

0

The following code works for me .

Set Conn = Server.Createobject("ADODB.Connection")  
Conn.open "Driver={Oracle in OraDb11g_home1};Server=10.11.201.170; Uid=USER;Pwd=PASSWORD;"
Christopher Marlowe
  • 2,098
  • 6
  • 38
  • 68
0

This is how I connect to Oracle using VBscript.

ConnectionString = "Driver={Microsoft ODBC for Oracle}; CONNECTSTRING=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=" + DBCONN + ")(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=" + DatabaseSID + " ))); uid=" + DatabaseUser + ";pwd=" + DatabasePassword + ";"

Set objConnection = CreateObject("ADODB.Connection") 

objConnection.Open ConnectionString
Jake
  • 397
  • 2
  • 15
0

I had a similar error when using classic ASP and Conn.Open "Provider=OraOLEDB.Oracle..." as is shown in the code above.

However, if I used Conn.Open "DSN=MyDSN;User ID=..." the connection worked.

In order to use the "Provider=OraOLEDB.Oracle..." syntax, I had to create a 32-bit application pool in IIS - create the application pool, then set Enable 32-Bit Applications = True (in advanced settings).

Note that 64-bit Windows has both 32 and 64-bit ODBC configurations. The default ODBC manager is 64-bit. Classic ASP applications can run in 64-bit mode and use 64-bit ODBC DSNs with some limitations like using Conn.Open "DSN=MyDSN;User ID=...".

If you use the Conn.Open "DSN=MyDSN..." syntax and you run in 32-bit mode, you will need to configure the DSN using the 32-bit ODBC manager. To access the 32-bit ODBC manager, run C:\Windows\SysWOW64\odbcad32.exe The 32-bit and 64-bit ODBC manager windows look identical - there will just be different lists of DSNs that are configured.

One other tool that I found helpful is to create a file named DBConnection.udl. (The file name is not important - just the .udl suffix.) When you double-click the file, a Data Link Properties window will open and allow you to select the provider and connection info. There is also a test button to verify your connection. After setting the connection variables, close the window and open the DBConnection.udl file with a text editor (notepad.exe works) and it will display the OLEDB init string that can be used in your application.

Kurt Schultz
  • 781
  • 5
  • 7