Friday, December 14, 2007

How to connect to database by using ADO connection?

How to connect to database by using ADO connection?

After we created the ADO Connection object, we can use it to connect to the database.

By using "Open" method, the ASP script will get the information from the database:

<%

Set conn = Server.CreateObject("Adodb.Connection")

conn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("db1.mdb")

' The Server.MapPath("db1.mdb") will get the actual path of the database in the web server

%>

No comments: