Hi guys
Yesterday I was contacted by one of the visitors after referring my posts about Classic ASP connection to Oracle databases in general & I revisited this “area” after a long time. It took a while for me to setup everything, however the results were pretty awesome. So here comes one more post about Classic ASP with Oracle database, this time Oracle 12c 64Bit.
OS: Windows 10/64Bit Windows Server OS
Prerequisites
- Setup IIS for publish classic ASP with Oracle 12c database
Software requirement(s):
- Oracle client 32Bit, 12c (for best connectivity)
Launch IIS and create a new application pool, as shown with the image.

Now go to the advanced settings for the application pool that you have created & switch “Enable 32-Bit Applications” from “false” to “True”

Connection possibilities
There are two ways to connect to Oracle database from Classic ASP
- Using DSN (Data Source Name)
- DSN less connections. Here we will use the Oracle tnsnames.ora file to identify and connect to the database. We have to insure that the TNS_HOME directory is set at the environment level, or the client that is used is 1st entry in the environment variable “PATH” for Oracle products in case of multi Oracle homed hosts.
Create a DSN
Classic ASP could interact with only 32Bit environment, hence the IIS server hosting machine must have the latest Oracle 32-Bit client installed (older clients may not connect to later databases properly). As I am writing this post, Oracle 12c 12.2.0 is the latest client available.
Logged with an account having “Administrator” privileges, Open ODBC Data Source (32-bit)

Please note, my box has multiple Oracle products, hence don’t get confused by the names in next few screens.

If your installation for the Oracle client was correct, you should able to see an entry for the Oracle driver like the one you could see the image above.
Click “Finish”. This will pop up another window. Under the “System DSN” tab we have to create our new DSN

Provide a name of your choice for the “Data Source Name” and “Description”
Make sure you have the “TNS Service Name” already available with the listener.ora file. Oracle 12c passwords are case sensitive. Hence make sure you are going to provide the case sensitive password while testing the connection.
If you don’t have previous experiences with creating net service names, please follow the instructions below.

Start “Net Configuration Assistant” from the Oracle Home and follow the images below.

Read the help texts available, especially if you are new to Oracle

Provide the service name, which is your database name usually.


Provide the FQDN (fully qualified domain name), ie, your computer name like “rajesh-pc.abc.com” in case if you are connected to a domain, else just the name of your computer, like “rajesh-pc”

I would suggest doing a test, if you are sure that all the details provided are correct & no need to test, you can skip this step


By default the configuration tool would suggest you the Oracle service name as new net service name, which you can change to any name. Just make sure that you will remember it.


Now let us test the new service name we have just created.

Once the Net Service Name is created, we will see both the scenarios using 2 different asp files, both using different connection approaches
(ASP sample was copied from here)
1. Connecting to 12c using DSN
[code language=”vb” gutter=”false”]
<html>
<head>
<title>Connecting to an Oracle database using ODBC and DSN connection</title>
</head>
<body>
<%
SET myConn=SERVER.createobject("adodb.connection")
myConn.Open "DSN=BAC;" & _
"Uid=APPS;" & "Pwd=APPS"
SQLStr="SELECT BANK_ID, BANK_NAME, BANK_TYPE FROM BAC_BANKS"
SET result=adoCon.execute(SQLStr)
IF NOT result.EOF thEN
response.write("<h2>Oracle ASP Example</h2>")
response.write("<p>Connecting to the Oracle11g database using ODBC & without a DSN</p>")
response.write("<table BORDER=3 BGCOLOR=#0099CC><tr><th>BANK ID</th>" & _
"<th>Name</th><th>TYPE</th>")
WHILE NOT result.EOF
response.write("<tr><td>" & result("BANK_ID") & "</td>")
response.write("<td>" & result("BANK_NAME") & "</td>")
response.write("<td>" & result("BANK_TYPE") & "</td></tr>")
result.movenext()
WEND
response.write("</table>")
ELSE
response.write("<p>Error retrieving bank data!!</p>")
END IF
adoCon.Close()
%>
</body>
</html>
[/code]
2. Connecting to 12c without DSN
[code language=”vb” gutter=”false”]
<%
Dim adoCon ‘Holds Connection
Dim rsViewRecords ‘Holds Record Set
‘ Initiate connection
Set adoCon = Server.CreateObject("ADODB.Connection")
adoCon.Open "provider=oraoledb.oracle;data source=SCT;user id=APPS;password=APPS"
if Err.Number <> 0 then
Response.Clear()
response.Write "<hr>ORASESSION Error<br>" & err.number & " — " & err.Description & "<hr>"
response.End
end if
SQLStr="SELECT BANK_ID, BANK_NAME, BANK_TYPE FROM BAC_BANKS"
SET result=adoCon.execute(SQLStr)
IF NOT result.EOF thEN
response.write("<h2>Oracle ASP Example</h2>")
response.write("<p>Connecting to the Oracle11g database using ODBC & without a DSN</p>")
response.write("<table BORDER=3 BGCOLOR=#0099CC><tr><th>BANK ID</th>" & _
"<th>Name</th><th>TYPE</th>")
WHILE NOT result.EOF
response.write("<tr><td>" & result("BANK_ID") & "</td>")
response.write("<td>" & result("BANK_NAME") & "</td>")
response.write("<td>" & result("BANK_TYPE") & "</td></tr>")
result.movenext()
WEND
response.write("</table>")
ELSE
response.write("<p>Error retrieving bank data!!</p>")
END IF
adoCon.Close()
%>
[/code]
Hope this helps few “Classic ASP” guys out there ;)
regards,
rajesh