Article View: borland.public.cppbuilder.database.ado
Article #1501Re: ADO Connection / Disconnection Help
From: Heinz
Date: Fri, 23 Apr 2004 14:12
Date: Fri, 23 Apr 2004 14:12
124 lines
5019 bytes
5019 bytes
I've removed the DataModuleCreate() ... Thanks
so I have now:
When I press Button 1 (Open Connection)
MyMainBody = new TTestDatabase(MyMainBodyForm);
<Test Connection with if/else statement>
When I press Button 3 (Querying my DB)
I first Close the Query / Clear the Query / Prep SQL Statement /
Open Query which is connected to a DBGrid.
ADOQuery1->Close();
ADOQuery1->Clear();
ADOQuery1->SQL->Add("Select Yakity Yak"); etc...
ADOQuery1->Open();
When I press Button 2 (Close Connection)
delete MyMainBody
<Test Connection with if/else statement>
Starting Out in this order:
I don't know if this will help you, but if I just push
Button3 it Query's and shows data... (Requests Login Prompt first)
Button2 closes Connection and data is nolonger shown
Repeating Above (Button3 then Button2)
The DBgrid shows data. (Which is what I want)
If I ever add pressing Button1, things don't pan out. Connect and Disconnect work, but the Query does not display any data. AFter that point, a query displaying data will never happen.
Thoughts? Suggestions?
Thanks for you help.
You seem to be the friendly helper in this news group.
Heinz
"Viatcheslav V. Vassiliev" <support@oledbdirect.com> wrote:
>> MyMainBody = new TTestDatabase(NULL);
>> MyMainBody->DataModuleCreate(MyMainBodyForm);
>
>Do not call DataModuleCreate() - it will be called automatically. If you
>need to specify owner, do it in new TTestDatabase(MyMainBodyForm). The same
>is for DataModuleDestroy().
>
>I do not see also where you close query (Query1->Active = false) and
>connection (MyADOConnection1->Connected = false) and where you destroy data
>module (delete MyMainBody).
>
>
>"Heinz" <pingpongoz@n0spam.h0tmail.n0spam.c0m> �������/�������� � ��������
>���������: news:4087e16f$1@newsgroups.borland.com...
>>
>> I've made a TTestDatabaseModule (type is a TDataModule) with a Constructor
>and Destructor.
>>
>> TTestDatabaseModule::DataModuleCreate(TObject *Sender)
>> {
>> MyADOConnection1->Open();
>> }
>>
>> TTestDatabaseModule::DataModuleDestroy(TObject *Sender)
>> {
>> MyADOConnection1->Close();
>> }
>>
>> In my MainForm, there are 3 Buttons:
>> Button1: Connect to my DB
>> Button2: Disconnect to my DB
>> Button3: Query a Table inside my DB
>>
>> For Button1:
>> I create an instance of my TTestDatabase and check for the Connection
>Status
>>
>> MyMainBody = new TTestDatabase(NULL);
>> MyMainBody->DataModuleCreate(MyMainBodyForm);
>>
>> <Check for Connected Property == true>
>> MyMainBody->MyADOConnection1->Connected == true
>> // Edit1 will show TRUE or FALSE string based on if/else condition
>>
>>
>> For Button2:
>> Do a Disconnection and check for the Connection Status
>>
>> MyMainBody->DataModuleDestroy(MyMainBodyForm);
>>
>> <Check for Connected Property == true>
>> MyMainBody->MyADOConnection1->Connected == true
>> // Edit1 will show TRUE or FALSE string based on if/else condition
>>
>> For Button3:
>> This Query is tide in with a TDBGrid on the MyMainBodyForm
>> <Some Query Statement that works>
>> SQL Statement something something
>> Query1->Open();
>> <Use see the Query on the Grid>
>>
>> Now my problem is:
>> I connect to the DB (Press Button1) - All is Okay (TRUE in Edit1)
>> I Query my DB (Press Button3) - All is Okay (I see my data in the TDBGrid)
>> I disconnect from my DB (Press Button2) - All is Okay (FALSE in Edit1)
>>
>> I try reconnecting:
>> I connect to the DB (Press Button1) - All is Okay (TRUE in Edit1)
>> I Query my DB (Press Button3) - I see nothing?
>> I disconnect from my DB (Press Button2) - All is Okay (FALSE in Edit1)
>>
>> Why is my Query on a Reconnect not displaying?
>> Is there a Disconnection problem? I'm not following through with
>something? The Builder help says Close or Active = false will kill the
>connection.
>>
>> Thanks for the help.
>> Heinz
>>
>>
>>
>>
>
>
Technical Details
Message-ID:
<4089243c$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!cyclone1.gnilink.net!gnilink.net!peer01.cox.net!cox.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<4087e16f$1@newsgroups.borland.com> <4087f08f$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 10698b,9fc947fa13652795 X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2004-04-23 07:31:25 PST From: "Heinz" <pingpongoz@n0spam.h0tmail.c0m.n0spam> Sender: "Heinz" <pingpongoz@n0spam.h0tmail.c0m.n0spam> Reply-To: "Heinz" <pingpongoz@n0spam.h0tmail.c0m.n0spam> Subject: Re: ADO Connection / Disconnection Help Newsgroups: borland.public.cppbuilder.database.ado X-User-Info: 146.131.120.2 References: <4087e16f$1@newsgroups.borland.com> <4087f08f$1@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <4089243c$1@newsgroups.borland.com> Date: 23 Apr 2004 07:12:12 -0700 X-Trace: newsgroups.borland.com 1082729532 207.105.83.66 (23 Apr 2004 07:12:12 -0700) Lines: 125 Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news.glorb.com!cyclone1.gnilink.net!gnilink.net!peer01.cox.net!cox.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail