如何判断adoconnection与服务器处于连接状态 ( 积分: 30 )

  • 主题发起人 主题发起人 gongfs
  • 开始时间 开始时间
G

gongfs

Unregistered / Unconfirmed
GUEST, unregistred user!
用adoconnection与sql server建立连接 adoconnection的keepconnection设为
true 请问我如何判断adoconnecton处于连接状态与断线状态 谢谢!
 
用adoconnection与sql server建立连接 adoconnection的keepconnection设为
true 请问我如何判断adoconnecton处于连接状态与断线状态 谢谢!
 
if (not) adoconnecton.active ...................
 
实验下:ADOConnection.State
Description

Use TObjectStates values to determine the current activity status of a connection or recordset.

The constants that make up the TObjectStates type correspond directly to the similarly named constants used for the State property of the ADO Connection, Command, and Recordset objects. For additional information on these ADO constants and their effects, see the Microsoft Data Access SDK help in the topic for the State property.
 
如果只是要判断是否连接,可直接用:
if adoconnection1.active=true then //为true时就代表连接
而如果要更详细的信息,可通过adoconnection.state来判断,其中state有以下几种:
TObjectState = (stClosed, stOpen, stConnecting, stExecuting, stFetching);
 
adoconnection1.active
 
各位大侠: 我怎么找不到adoconnection的active属性
 
哦,寫錯了寫錯了,都是被上面的人誤導的,應該是:
if adoconnection1.connected=true then
//
 
多人接受答案了。
 
后退
顶部