ConnectionString Property - ADO

简介: 今天进行一个学生信息系统的查询开发时,发现老师给的数据库(Access)有密码,不知道怎么连接了,在通常的数据连接中,我添加了password属性后,提示说我的密码错误,无法连接,刷新了一下后提示说:“文件正在使用或其他的程序以独占的方式打开了”,怎么办,以前没有遇到过此类问题啊!傻了,那就看看MSDN 的帮助,以下是查询的connectionString的说明,简单的翻译以下(红色的部分翻译得不好,希望大家帮忙看看)。

今天进行一个学生信息系统的查询开发时,发现老师给的数据库(Access)有密码,不知道怎么连接了,在通常的数据连接中,我添加了password属性后,提示说我的密码错误,无法连接,刷新了一下后提示说:“文件正在使用或其他的程序以独占的方式打开了”,怎么办,以前没有遇到过此类问题啊!傻了,那就看看MSDN 的帮助,以下是查询的connectionString的说明,简单的翻译以下(红色的部分翻译得不好,希望大家帮忙看看)。

ConnectionString Property - ADO

Contains the information used to establish a connection to a data source.

提供给connection的数据库连接的信息,返回值为一个字符串

Applies To

Connection

Settings and Return Values

Sets or returns a String value.

Remarks

Use the ConnectionString property to specify a data source by passing a detailed connection string containing a series of argument = value statements separated by semicolons.

使用ConnectionStrin属性的一系列的“argument = value”的参数连接到一个特定的数据库,连接的参数采用“;”隔离。ADO为ConnectionStrin提供7个连接参数,其他的参数直接由提供者而不是ADO。ADO支持的参数如下:

ADO supports seven arguments for the ConnectionString property; any other arguments pass directly to the provider without any processing by ADO. The arguments ADO supports are as follows:

Argument

Description

 

 

Provider=

Specifies the name of a provider to use for the connection.

Data Source=

Specifies the name of a data source for the connection, for example, a SQL Server database registered as an ODBC data source.

User ID=

Specifies the user name to use when opening the connection.

Password=

Specifies the password to use when opening the connection.

File Name=

Specifies the name of a provider-specific file (for example, a persisted data source object) containing preset connection information.

Remote Provider=

Specifies the name of a provider to use when opening a client-side connection. (Remote Data Service only.)

Remote Server=

Specifies the path name of the sever to use when opening a client-side connection. (Remote Data Service only.)

参数

描述

 

 

Provider=

指定连接的提供者

Data Source=

指定连接的数据源。比如:一个SQL服务器数据库被注册为ODBC数据源。

User ID=

打开数据库用户名

Password=

打开数据库的密码

File Name=

Specifies the name of a provider-specific file (for example, a persisted data source object) containing preset connection information.

指定提供者的特定的文件名(例如:一个XX的数据库对象),该文件包含连接信息

Remote Provider=

当打开一个客户端连接时,指定一个服务提供名(仅使用于远程数据库)

Remote Server=

当打开一个客户端连接时,指定服务器的名称(仅使用于远程数据库)

 

After you set the ConnectionString property and open the Connection object, the provider may alter the contents of the property, for example, by mapping the ADO-defined argument names to their provider equivalents.

当打开Connection对象,并为其设置了ConnectionString对象时,提供者将显示属性的内容。比如:通过影射ADO定义参数,命名提供者的对象。

The ConnectionString property automatically inherits the value used for the ConnectionString argument of the Open method, so you can override the current ConnectionString property during the Open method call.

通过Open方法,ConnectionString能自动的插入参数值,所以通过调用Open方法可以重载当前的ConnectionString属性。

Because the File Name argument causes ADO to load the associated provider, you cannot pass both the Provider and File Name arguments.

因为File Name参数可以引起ADO加载自定义的提供者,你不能同时加载Provider和File Name参数属性。

The ConnectionString property is read/write when the connection is closed and read-only when it is open.

Connection关闭时,ConnectionString是可读写的;连接打开时,ConnectionString又是只读的。

Remote Data Service Usage When used on a client-side Connection object, the ConnectionString property can only include the Remote Provider and Remote Server parameters.

远程数据服务的使用方法:当使用客户端连接对象时,ConnectionString属性只包含Remote Provider和Remote Server 参数属性。

Examples

ConnectionString, ConnectionTimeout, and State Properties Example (VB)

See Also

Using OLE DB Providers with ADO

 

目录
相关文章
|
10月前
|
数据库
利用ADO连接数据库
利用ADO连接数据库
|
10月前
|
SQL 数据库连接 API
ODBC与ADO的区别
ODBC与ADO的区别
90 0
|
SQL 存储 小程序
ADO与ODBC用法
ADO与ODBC用法
163 0
|
SQL 存储 数据库连接
ADO,OLEDB,ODBC,DAO的区别
ODBC(Open Database Connectivity,开放数据库互连) 1992年,微软公司开放服务结构(WOSA,Windows Open Services Architecture)中有关数据库的一个组成部分,它建立了一组规范,并提供了一组对数据库访问的标准API(应用程序编程接口)。
2422 0
|
数据库 .NET 开发框架
【译】EntityFramework6与EntityFrameworkCore的区别
EntityFramework6 EF6 是一个久经考验的数据库访问技术,发展多年,拥有许多特性,并且成熟稳定。2008年EF作为 .Net 3.5 Sp1 和Visual Studio 2008 SP1 的一部分首次发布。
1383 0