Connecting to Oracle using OLE and a DSNLess Connection

Source Code

the example below uses a DSNLess connection called oracle12c. this is setup in the TNSNAMES.ORA file found on the IIS server. In this case, the MSDAORA provider uses an OLE driver. Note, the syntax for the connection string differs from the ODBC example.

<title>Connecting to an Oracle database using OLE and DSNLess connection</title>

SET myConn=SERVER.createobject("adodb.connection")
myConn.Open "Provider=MSDAORA; Data Source=ora12c;" & _
"User ID=myOracleUsername;" & "Password=myOraclePassword"
SQLStr="SELECT empno, ename, deptno FROM Emp ORDER BY deptno, ename"
SET result=myConn.execute(SQLStr)
IF NOT result.EOF thEN
  response.write("<h2>Oracle ASP Example</h2>")
  response.write("<p>Connecting to Oracle using OLE & DSNLess connection</p>")
  response.write("<table border=3 bgcolor=#0099CC><tr>" & _
    "<th>Employee No</th><th>Name</th><th>Department No</th>")
  WHILE NOT result.EOF
    response.write("<tr><td>" & result("empno") & "</td>")
    response.write("<td>" & result("ename") & "</td>")
    response.write("<td>" & result("deptno") & "</td></tr>")
  response.write("<p>Error retrieving Employee data!!</p>")


Click here to run the program