🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.database.ado
2 messages
2 total messages Started by Borland News Wed, 21 Feb 2001 05:50
Beginner Help: User TADOConnection->State
#5710
Author: Borland News
Date: Wed, 21 Feb 2001 05:50
9 lines
1093 bytes
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
Re: Beginner Help: User TADOConnection->State
#5755
Author: Alexander Liffers
Date: Tue, 06 Mar 2001 02:17
38 lines
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
>
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads