Ado Connect
# ADO Database Connection
* * *
Before accessing data from a web page, a database connection must first be established.
* * *
## Creating a DSN-less Database Connection
The simplest way to connect to a database is to use a DSN-less connection. A DSN-less connection can be used with any Microsoft Access database on your site.
Assume you have a database named "northwind.mdb" located in the web directory "c:/webdata/". 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 to the database on the computer.
* * *
## Creating an ODBC Database Connection
Assume 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 an ODBC connection is available.
* * *
## ODBC Connection to MS Access Database
Here is how to create a connection to an MS Access database:
1. Open the _ODBC_ icon in the Control Panel
2. Select the System _ODBC DSN_ tab
3. Click the _Add_ button in the ODBC tab
4. _Select_ Driver to Microsoft Access, then click the _Finish_ button
5. In the next window, click the "Select" button to locate the database
6. Give this database a Data Source Name (_D_ ata _S_ ource _N_ ame, DSN)
7. Click "_OK_"
Note: This configuration must be done on the computer where your website is located. If you are running PWS or IIS on your own computer, this setup will work. However, if your website is on a remote server, you must have physical access to that server or ask your web hosting provider to do this for you.
* * *
## 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.
See all methods and properties of the Connection Object.
YouTip