2.2.3. ADO database connection

发布时间 : 2025-10-25 13:35:18 UTC      

Page Views: 9 views

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.

《地理信息系统原理、技术与方法》  97

最近几年来,地理信息系统无论是在理论上还是应用上都处在一个飞速发展的阶段。 GIS被应用于多个领域的建模和决策支持,如城市管理、区划、环境整治等等,地理信息成为信息时代重要的组成部分之一; “数字地球”概念的提出,更进一步推动了作为其技术支撑的GIS的发展。 与此同时,一些学者致力于相关的理论研究,如空间感知、空间数据误差、空间关系的形式化等等。 这恰好说明了地理信息系统作为应用技术和学科的两个方面,并且这两个方面构成了相互促进的发展过程。