Latest web development tutorials

ADO database connection

Before accessing data from a webpage, you must first establish a database connection.


Creating a DSN-less Database Connection

The easiest way to connect to a particular database is to use a DSN-less connection. DSN-less connections can be used with any Microsoft Access database on your site.

Suppose you have a database called "northwind.mdb" located in "c: / webdata /" in the web directory, you can use the following ASP code to connect to the 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 the Microsoft Access database driver (Provider), as well as the physical path of the database on the computer.


Create an ODBC database connection

Suppose you have an ODBC database called "northwind" you can use the following ASP code to connect to the database:

<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Open "northwind"
%>

Via an ODBC connection, you can connect to your network in any database on any computer, as long as an ODBC connection is available.


h2> to ODBC MS Access database connection

Here to show you how to create a connection to a MS Access database:

  1. Open the Control Panel ODBC icon
  2. Select System ODBC tab
  3. Click the ODBC tab of the Add button
  4. Select the Driver to Microsoft Access, and then click the Done button
  5. In the next window, click on the "Select" button to locate the database
  6. Given a data source name (D ata S ource N ame, DSN) for this database
  7. Click "OK"

Note: This configuration must be completed on the computer where your web site. If you are running IIS or PWS on your computer, this architecture can run, but if your site is located on a remote server, you must have physical access to the server, or ask your web hosting provider for you to do these things.


ADO connection object (ADO Connection Object)

ADO connection object used to create an open connection to a data source. With this connection, you can access this database and perform operations.

See this connection object of all methods and properties.