Article View: borland.public.cppbuilder.database.ado
Article #5755Re: Beginner Help: User TADOConnection->State
From: Alexander Liffers
Date: Tue, 06 Mar 2001 02:17
Date: Tue, 06 Mar 2001 02:17
38 lines
2051 bytes
2051 bytes
If your application is multi-threaded, or these functions are in a shared
DLL/BPL make sure you use a TCriticalSection to aquire a lock so that only
one thread actually attempts to reconnect, otherwise as simple as follows:
if (myConnection->State == stClosed)
try { myConnection->Open (); }
catch (Exception& e) { Application->ShowException (&e); }
for the multi-threaded I'd suggest:
if (myConnection->State == stClosed) {
myCS->Aquire ();
// check again incase it was opened while waiting for the lock:
if (myConnection->State == stClosed) {
try { myConnection->Open (); }
catch (Exception& e) { Application->ShowException (&e); }
}
myCS->Release ();
}
"Borland News" <wangha@hkucc.hku.hk> wrote in message
news:3a9356b1$1_1@dnews...
> Dear All,
>
> I am a beginner of C++ Builder. I want to use TADOConnection->State to get
> the database's connecton status. And if the state is closed system should
> connect it again. How can I do it?
>
> Thanks
>
> WHB
>
>
Technical Details
Message-ID:
<983845626.348668@wolf.foxgold.net.au>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!bornews.borland.com!dnews!203.132.107.35References:
<3a9356b1$1_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,d9a3834368b206b1 X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2001-03-05 18:30:07 PST From: "Alexander Liffers" <alex@foxgold.net.au> Newsgroups: borland.public.cppbuilder.database.ado References: <3a9356b1$1_1@dnews> Subject: Re: Beginner Help: User TADOConnection->State Date: Tue, 6 Mar 2001 10:17:06 +0800 Lines: 40 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Organization: Foxgold Pty Ltd Message-ID: <983845626.348668@wolf.foxgold.net.au> Cache-Post-Path: wolf.foxgold.net.au!unknown@mail.algarburns.com.au X-Cache: nntpcache 2.3.3 (see http://www.nntpcache.org/) NNTP-Posting-Host: 203.132.107.35 X-Trace: 5 Mar 2001 18:15:32 -0800, 203.132.107.35 Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-03!supernews.com!newsfeed.wirehub.nl!PeerFeed.KWeb.on.ca!bornews.borland.com!dnews!203.132.107.35