How to connect to an Oracle database by using ASP and ADO (193225)



The information in this article applies to:

  • Microsoft Active Server Pages
  • Microsoft Internet Information Services version 6.0
  • Microsoft Data Access Components

This article was previously published under Q193225

INTRODUCTION

This article discusses how to connect to an Oracle database by using a Microsoft Active Server Pages (ASP) page and Microsoft ActiveX Data Objects (ADO).

MORE INFORMATION

To connect to an Oracle database, you can create an ASP page that contains the following code.

Note Make sure that the connect string has a valid user ID and password and that the SQL statement references a valid table.
   <%@ Language=VBScript %>
   <html>
   <head>
   <title>Oracle Test</title>
   </head>
   <body>
   <center>
   <%
     Set objConn = Server.CreateObject("ADODB.Connection")
     objConn.Open "Provider=MSDAORA;Data Source=<Your_TNSNames_Alias>;User Id=<userid>;Password=<password>;"

     Set objRs = objConn.Execute("SELECT * FROM DEMO.EMPLOYEE")

     Response.Write "<table border=1 cellpadding=4>"
     Response.Write "<tr>"

     For I = 0 To objRS.Fields.Count - 1
       Response.Write "<td><b>" & objRS(I).Name & "</b></td>"
     Next

     Response.Write "</tr>"

     Do While Not objRS.EOF
       Response.Write "<tr>"

       For I = 0 To objRS.Fields.Count - 1
         Response.Write "<td>" & objRS(I) & "</td>"
       Next

       Response.Write "</tr>"

       objRS.MoveNext
     Loop

     Response.Write "</table>"

     objRs.Close
     objConn.Close
   %>
   </center>
   </body>
   </html>
				

REFERENCES

For more information about how to connect to an Oracle database, click the following article number to view the article in the Microsoft Knowledge Base:

178391 Oracle TNS: Authentication service initialization error

For more information about the Microsoft ODBC Driver for Oracle and the Microsoft OLE DB Provider for Oracle, click the following article number to view the article in the Microsoft Knowledge Base:

244661 Limitations of Microsoft Oracle ODBC Driver and OLEDB Provider

For more information about how to contact Oracle, click the following article number to view the article in the Microsoft Knowledge Base:

60781 Hardware and software vendor contact information, L-P

Microsoft provides third-party contact information to help you find technical support. This contact information may change without notice. Microsoft does not guarantee the accuracy of this third-party contact information.

The third-party products that this article discusses are manufactured by companies that are independent of Microsoft. Microsoft makes no warranty, implied or otherwise, regarding the performance or reliability of these products.

Modification Type:MajorLast Reviewed:3/17/2006
Keywords:kbDatabase kbhowto kbOracle KB193225 kbAudDeveloper kbAudITPRO