Before you can access data from a web page, you must establish a database connection. The easiest 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 that you have a database named “northwind.mdb” in the web directory of “c:/webdata/”, you can connect to this database using the following ASP code: Note that in the above example, you must specify Microsoft’s Access databasedriver (Provider) and the physical path of this database on the computer. Suppose you have an ODBC database named “northwind” and you can connect toit using the following ASP code: With an ODBC connection, you can connect to any database on any computer on your network, as long as the ODBC connection is available. 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 and click the finish button Click the Select button in the next window to locate the database Assign a data source name (Data Source Name,DSN) to this database Click “OK” Note: this configuration must be done on the same computer as your website. This architecture works if you are running PWS or IIS on your computer, but if your Web site is located on a remote server, you must have physical access to that server, or ask your web host provider to do these things for you. The ADO connection object is used to create an open connection to a data source. Through this connection, you can access and manipulate this database. View all the methods and properties of this connection object.Create a DSN-less database connection ¶
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
%>
Create an ODBC database connection ¶
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Open "northwind"
%>
ODBC connection to MS Access database ¶
ADO Connection Object ¶