BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TADOConnection not disconnecting problem

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO)
View previous topic :: View next topic  
Author Message
Bob Dalton
Guest





PostPosted: Wed Sep 10, 2003 2:23 am    Post subject: TADOConnection not disconnecting problem Reply with quote



Situation: My app connects the first time to MSSQL 2000 without a hitch
using the Delphi 7 TADOConnection component. In the app I have a utility to
allow a user to change the connection string either BEFORE the first time
connection is made or after first time connection to allow for changing the
connection if need be. In the second case the following code is done prior
to running a unit to configure the connection string and make the
connection:

ADOConnection.Close;
ADOConnection.ConnectionString := '';

These statements should both disconnect the component and clear the connect
string.
BTW the connectionstring is blank at design time and only filled in at run
time. Also the cennected property is set to false at design time.

Problem: Despite using the code above the TADOConnection apparently was NOT
closed. I have also tried using ADOConnection.Connected := False in place of
ADOConnection.Close with no change in results. A check of the connection
string show it clear as it should be based on the statement above. This
would seem to indicate a problem with the ADOConnection component not
freeing up the connection despite my attempts to do so.

I have tried everything I can think of without any success. Anyone got a
answer for this out there?

Regards;

Bob Dalton


Back to top
Shiv Kumar
Guest





PostPosted: Wed Sep 10, 2003 5:22 am    Post subject: Re: TADOConnection not disconnecting problem Reply with quote



Bob,

I just tried this and it works for me.

Quote:
A check of the connection
string show it clear as it should be based on the statement above

Can you explain that please?

What error do you get, if any?
--
Shiv R. Kumar
The Delphi Apostle
http://www.matlus.com



Back to top
Bob Dalton
Guest





PostPosted: Wed Sep 10, 2003 5:10 pm    Post subject: Re: TADOConnection not disconnecting problem Reply with quote



Quote:
A check of the connection
string show it clear as it should be based on the statement above
Can you explain that please?

ADOConnection.ConnectionString := '';

I check to make sure that the connectionstring property really does = ''

No error reported and that's not the problem. The problem is that despite my
setting ADOConnection.connected to false and the connectionstring to '' the
connection is still being maintained (and nothing in my App is using that
connection at the time). As a result my logic which counts on the connection
being broken/down does not work....

BTW I am using MDAC 2.8 with MSSQL Server 2000.

Flow chart of activity:

1. App launches
2. User clicks button which reads an ini file for an existing connection
string and makes the connection if a connection string is found in the ini
file.
3. If an existing connection string is not found the connection editor is
run to make one.
4. After connection string is made then connection is established.
Everything is fine to this point....
5. Now user decides he wants to edit the connection string even though
he/she is already connected and calls up my utility to do that.
6. The utility clears the existing connection string, sets the connected
property to false. This should break/close down the connection.
7. A test is made to check for true disconnection. If disconnected the
connection string editor pops up so the user can make a new one.

Note: Step 7 is where it fails. The test shows the TADOConnection component
is still connected and it should not be...

Regards;

Bob Dalton



Back to top
Shiv Kumar
Guest





PostPosted: Wed Sep 10, 2003 9:30 pm    Post subject: Re: TADOConnection not disconnecting problem Reply with quote


Quote:
7. A test is made to check for true disconnection. If disconnected the
connection string editor pops up so the user can make a new one.

Note: Step 7 is where it fails. The test shows the TADOConnection
component
is still connected and it should not be...

Ok, I simply replace the connection string and set the connected := True;
property and it switches.
--
Shiv R. Kumar
The Delphi Apostle
http://www.matlus.com




Back to top
Bob Dalton
Guest





PostPosted: Thu Sep 11, 2003 12:00 am    Post subject: Re: TADOConnection not disconnecting problem Reply with quote

Maybe I am missing something here.

Question 1: Are you using my source code example?

Question 2: Are you clicking the "Connect" button first and then after the
connection is made THEN clicking the "Edit Connection" button? Only this
sequence shows the problem.....

Question 3: If the connection editor does not pop up, as it should, then
how are you "replacing" the connection string based on my source code? Are
you saying that in step seven, based on my source code and the sequence I
out line above, you are getting the connection editor popping up?

Question 4: Are you using MDAC 2.8?

Thanks for your assistance.....

Regards;

Bob Dalton

"Shiv Kumar" <shivk (AT) erols (DOT) com> wrote

Quote:

7. A test is made to check for true disconnection. If disconnected the
connection string editor pops up so the user can make a new one.

Note: Step 7 is where it fails. The test shows the TADOConnection
component
is still connected and it should not be...

Ok, I simply replace the connection string and set the connected := True;
property and it switches.
--
Shiv R. Kumar
The Delphi Apostle
http://www.matlus.com





Back to top
Shiv Kumar
Guest





PostPosted: Thu Sep 11, 2003 3:35 am    Post subject: Re: TADOConnection not disconnecting problem Reply with quote

Bob,

Maybe I should have clarified...

I do this all the time in my own applications, so I tried it once again
(since I had recently installed MDAC 2.Cool and it works as expected.

I use a connection string to connect. Then I disconnect. Change the
connection string and connect again and it connects to the second
server/database etc.

--
Shiv R. Kumar
The Delphi Apostle
http://www.matlus.com


Back to top
Bob Dalton
Guest





PostPosted: Thu Sep 11, 2003 1:12 pm    Post subject: Re: TADOConnection not disconnecting problem Reply with quote

I appreciate your attemtping to help me, and I understand what you are
saying below, but the lack of context and details in your answers often
leaves me more confused then enlightened.

Please answer just one question: Did you get the results below using my
source code project or was it using your own code?

Regards;

Bob Dalton

"Shiv Kumar" <shivk (AT) erols (DOT) com> wrote

Quote:
Bob,

Maybe I should have clarified...

I do this all the time in my own applications, so I tried it once again
(since I had recently installed MDAC 2.Cool and it works as expected.

I use a connection string to connect. Then I disconnect. Change the
connection string and connect again and it connects to the second
server/database etc.

--
Shiv R. Kumar
The Delphi Apostle
http://www.matlus.com






Back to top
Bob Dalton
Guest





PostPosted: Thu Sep 11, 2003 2:52 pm    Post subject: Re: TADOConnection not disconnecting problem Reply with quote

Never mind I have found a work around. Thanks anyway....

Regards;

Bob Dalton


Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.