ADO Database Connection
- Previous Page ADO Introduction
- Next Page ADO Recordset
Before accessing data from a web page, you must first establish a database connection.
Create a DSN-less database connection
The simplest way to connect to a database is to use a DSN-less connection. DSN-less connections can be used for any Microsoft Access database on your site.
Assuming you have a database named "northwind.mdb" located in the web directory at "c:/webdata/", you can use the following ASP code to connect to this database:
<% set conn=Server.CreateObject("ADODB.Connection") conn.Provider="Microsoft.Jet.OLEDB.4.0" conn.Open "c:/webdata/northwind.mdb" %>
Note that in the above example, you must specify Microsoft's Access database driver (Provider), as well as the physical path to this database on the computer.
Create an ODBC database connection
Assuming you have an ODBC database named "northwind", you can use the following ASP code to connect to this database:
<% set conn=Server.CreateObject("ADODB.Connection") conn.Open "northwind" %>
Through an ODBC connection, you can connect to any database on any computer in your network, as long as the ODBC connection is available.
ODBC connection to MS Access database
Here is an explanation of how to create a connection to an MS Access database:
- Open the control panel's ODBC Icon
- Select System ODBC Tab
- Click theAddButton
- Select Driver to Microsoft Access, then clickFinishButton
- Click the "Select" button in the next window to locate the database
- Assign a data source name (DData SSource Name, DSN)
- Click "OK"
Note:This configuration must be completed on the computer where your website is located. If you are running PWS or IIS on your own computer, this architecture can run, but if your website is located on a remote server, you must have physical access to this server, or you can ask your web hosting provider to do these things for you.
ADO Connection Object (ADO Connection Object)
The ADO Connection Object is used to create an open connection to a data source. Through this connection, you can access and operate on this database.
View all methods and properties of this connection object.
- Previous Page ADO Introduction
- Next Page ADO Recordset