2.2.3. ADO database connection

发布时间 :2025-10-25 12:23:18 UTC      

Before you can access data from a web page, you must establish a database connection.

Create a DSN-less 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:

<%
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 databasedriver (Provider) and the physical path of this database on the computer.

Create an ODBC database connection

Suppose you have an ODBC database named “northwind” and you can connect toit using the following ASP code:

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

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

ODBC connection to MS Access database

Here’s how to create a connection to an MS Access database:

  1. Open the ODBC icon in the control panel

  2. Select the system ODBC tab

  3. Click the add button in the ODBC tab

  4. Select Driver to Microsoft Access and click the finish button

  5. Click the Select button in the next window to locate the database

  6. Assign a data source name (Data Source Name,DSN) to this database

  7. 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.

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 this database.

View all the methods and properties of this connection object.

Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.