次の方法で共有


IsConnected (clsDataSource)

ms135463.note(ja-jp,SQL.90).gifメモ :
  この機能は、Microsoft SQL Server の次のバージョンで削除されます。新規の開発作業ではこの機能を使用しないようにし、現在この機能を使用しているアプリケーションはできるだけ早く修正してください。

The IsConnected method of an object of ClassType clsDataSource verifies the connection to the data source specified by the ConnectionString property. If the data source is not connected, the method attempts to connect to the source.

構文

bRet = object.IsConnected(ErrorMsg As String)

パラメータ

  • bRet
    A Boolean variable that receives the returned value: True is returned if the data source is connected, False if the connection cannot be established.
  • object
    An object of ClassTypeclsDataSource.
  • ErrorMsg
    An optional string variable that receives the error definition if the connection cannot be established.

解説

If the data source is already connected when the method is executed, the method returns True. If the data source is not connected, the method attempts to connect to the data source, returning True if the connection is established or False if the connection cannot be established.

It is not necessary to establish a connection to a data source before it can be used. Decision Support Objects (DSO) will automatically establish the connection when necessary (for example, to read a property value from the source database or to access data in the database).

使用例

Use the following code to establish a connection to a data source with the IsConnected property:

'Assume an object (dsoDS) of ClassType clsDataSource exists 
If Not dsoDS.IsConnected Then
   ' Code to handle connection error
Else 
   ' Connection is established 
End If 

参照

関連項目

clsDataSource
ConnectionString (clsDataSource)

ヘルプおよび情報

SQL Server 2005 の参考資料の入手