ADO Database Connection
Before accessing data from a web page, you must first establish a database connection.
Creating a DSN-less Database Connection
The simplest way to connect to a database is by using a DSN-less connection. A DSN-less connection can be used for any Microsoft Access database on your site.
Suppose you have a database named "northwind.mdb" located in the "c:/webdata/" web directory, you can use the following ASP code to connect to this database:
Note that in the example above, you must specify the Microsoft Access database driver (Provider) and the physical path of the database on the computer.
Creating an ODBC Database Connection
Suppose you have an ODBC database named "northwind", you can use the following ASP code to connect to this database:
With 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 an MS Access Database
Here's how to create a connection to an MS Access database:
- Open the ODBC icon in the Control Panel
- Select the system ODBC tab
- Click the Add button in the ODBC tab
- Select Driver to Microsoft Access, then click the Finish button
- Click the "Select" button in the next window to locate the database
- Assign a Data Source Name (DSN) to this database
- Click "OK"
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 manipulate the database.
View all methods and properties of this connection object.