开发者

how can I check if a tsqlconnection is open?

开发者 https://www.devze.com 2023-02-07 18:48 出处:网络
after an unsuccesfull login: mytsqlconnection->Open(); if(mytsqlconnection->ConnectionState == cs开发者_JS百科StateOpen)

after an unsuccesfull login:

mytsqlconnection->Open();
if(mytsqlconnection->ConnectionState == cs开发者_JS百科StateOpen)
{
 ...
}

the "if" returns true. How can I check if the connection is really open? Do I have to execute a query and catch the exception? Thanks in advance.

Francesco


If the login fails, Open() should be raising an exception. The ConnectionState property is not set to csStateOpen unless Open() is successful in establishing a connection to the DB without error.


It was a matter of driver. I used the dbexpora.dll that came with cppbuilder6 (right-click on dbexpora.dll give no info about version). I change driver and everything works fine: Open() raise the exception, ConnectionState is set as expected. Thankyou.

Francesco

0

精彩评论

暂无评论...
验证码 换一张
取 消