ConnectionString Property - ADO
今天進行一個學生信息系統(tǒng)的查詢開發(fā)時,發(fā)現(xiàn)老師給的數(shù)據(jù)庫(Access)有密碼,不知道怎么連接了,在通常的數(shù)據(jù)連接中,我添加了password屬性后,提示說我的密碼錯誤,無法連接,刷新了一下后提示說:“文件正在使用或其他的程序以獨占的方式打開了”,怎么辦,以前沒有遇到過此類問題啊!傻了,那就看看MSDN 的幫助,以下是查詢的connectionString的說明,簡單的翻譯以下(紅色的部分翻譯得不好,希望大家?guī)兔纯?。
ConnectionString Property - ADO
Contains the information used to establish a connection to a data source.
提供給connection的數(shù)據(jù)庫連接的信息,返回值為一個字符串
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”的參數(shù)連接到一個特定的數(shù)據(jù)庫,連接的參數(shù)采用“;”隔離。ADO為ConnectionStrin提供7個連接參數(shù),其他的參數(shù)直接由提供者而不是ADO。ADO支持的參數(shù)如下:
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.) |
參數(shù) | 描述 |
? | ? |
Provider= | 指定連接的提供者 |
Data Source= | 指定連接的數(shù)據(jù)源。比如:一個SQL服務(wù)器數(shù)據(jù)庫被注冊為ODBC數(shù)據(jù)源。 |
User ID= | 打開數(shù)據(jù)庫用戶名 |
Password= | 打開數(shù)據(jù)庫的密碼 |
File Name= | Specifies the name of a provider-specific file (for example, a persisted data source object) containing preset connection information. 指定提供者的特定的文件名(例如:一個XX的數(shù)據(jù)庫對象),該文件包含連接信息 |
Remote Provider= | 當打開一個客戶端連接時,指定一個服務(wù)提供名(僅使用于遠程數(shù)據(jù)庫) |
Remote Server= | 當打開一個客戶端連接時,指定服務(wù)器的名稱(僅使用于遠程數(shù)據(jù)庫) |
?
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對象,并為其設(shè)置了ConnectionString對象時,提供者將顯示屬性的內(nèi)容。比如:通過影射ADO定義參數(shù),命名提供者的對象。
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能自動的插入?yún)?shù)值,所以通過調(diào)用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參數(shù)可以引起ADO加載自定義的提供者,你不能同時加載Provider和File Name參數(shù)屬性。
The ConnectionString property is read/write when the connection is closed and read-only when it is open.
當Connection關(guān)閉時,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.
遠程數(shù)據(jù)服務(wù)的使用方法:當使用客戶端連接對象時,ConnectionString屬性只包含Remote Provider和Remote Server 參數(shù)屬性。
Examples
ConnectionString, ConnectionTimeout, and State Properties Example (VB)
See Also
Using OLE DB Providers with ADO
?
轉(zhuǎn)載于:https://www.cnblogs.com/AloneSword/archive/2005/11/03/2237647.html
總結(jié)
以上是生活随笔為你收集整理的ConnectionString Property - ADO的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 在C++ Builder中用socket
- 下一篇: 在迷失中前进--hatita22年蹉跎岁