当前位置: 首页 > 网络学院 > 服务端脚本教程 > ADO > ADO数据库连接

ADO
ADO介绍
ADO数据库连接
ADO记录集
ADO显示记录
ADO查询语句
ADO记录排序
ADO添加记录
ADO更新记录
ADO删除记录
ADO演示
ADO提升执行速度
ADO Command对象
ADO Connection对象
ADO Error
ADO Field
ADO Parameter
ADO 属性
ADO Record
ADO Recordset
ADO Stream

ADO 中的 ADO数据库连接


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 1078 ::
收藏到网摘: n/a

Before a database can be accessed from a web page, a database connection has to be established.
在数据库能够被WEB页面使用以前,一条关联到数据库的连接必须先建立起来


Create a DSN-less Database Connection
建立DSN-less数据库连接

The easiest way to connect to a database is to use a DSN-less connection. A DSN-less connection can be used against any Microsoft Access database on your web site.
最简单的连接方法是使用DSN-less连接。这种连接方式对于MS中的任何Access数据库都可以使用。

If you have a database called "northwind.mdb" located in a web directory like "c:/webdata/", you can connect to the database with the following ASP code:
如果你在本地WEB目录下已经包含了一名为northwind.mdb的数据库。比如"c:/webdata/",那么你就可以使用下面这段ASP代码来连接到数据库上:

<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "c:/webdata/northwind.mdb"
%>

Note, from the example above, that you have to specify the Microsoft Access database driver (Provider) and the physical path to the database on your computer.
要注意,必须得指定数据库的提供者(Provider)以及物理位置(相对位置也行)


Create an ODBC Database Connection
建立ODBC数据库连接

If you have an ODBC database called "northwind" you can connect to the database with the following ASP code:
如果你的计算机上已经有名为"northwind"的ODBC数据库,那么你可以用下面这段ASP代码来连接到数据库上:

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

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连接就可以让你连接到任何一种数据库,或是任何在网络上的有此数据库的计算机,当然了这条连接必须是有效的。


An ODBC Connection to an MS Access Database
用ODBC连接到MS Aceess数据库

Here is how to create a connection to a MS Access Database: 
这里就是怎样连接到MS Access数据库的方法

  1. Open the ODBC icon in your Control Panel.
    在你的控制面板中打开ODBC的图标
  2. Choose the System DSN tab.
    选择 System DSN[系统DSN]
  3. Click on Add in the System DSN tab.
    选中 添加 系统DSN
  4. Select the Microsoft Access Driver. Click Finish.
    选择 Microsoft Access Driver。点完成
  5. In the next screen, click Select to locate the database.
    在接下来,点击 选择 然后选中本地数据库
  6. Give the database a Data Source Name (DSN).
    给这个数据库起个名字
  7. Click OK.
    完成了

Note that this configuration has to be done on the computer where your web site is located. If you are running Personal Web Server (PWS) or Internet Information Server (IIS) on your own computer, the instructions above will work, but if your web site is located on a remote server, you have to have physical access to that server, or ask your web host to do this for you. 
(不确定)注意:在你的网站已经设置好了以后,这个配置才能安装。如果你在你自己的电脑里运行PWS个人WEB服务器或者网络信息服务器IIS,以上的指示都要工作。但是如果你的网页是在远程服务器里,你必须有密码,或者要求你的网络主机商为你做这些工作。


 

The ADO Connection Object
ADO 连接对象

The ADO Connection object is used to create an open connection to a data source. Through this connection, you can access and manipulate a database.
ADO Connection对象用来建立打开数据源的连接,通过这条连接,你就能使用并操作数据库

View all methods and properties of the Connection object.
查看所有Connection对象的方法和属性

评论 (0) All

登陆 | 还没注册?