Page 1 of 1

Disconnected Mode

Posted: Wed 12 Sep 2007 17:44
by PoSeiDoN31
Hi I've been working with MyDac and I've created an application connecting to MySql. I'm working with disconnected mode and pooling, but i was testing some problems and i completely disconnect the TMyConnection component, this means, that i set the properties:
- Connected = false
- Disconnected Mode = false
- Pooling = false.
The problem is that when i open the TMyQuery component, it connects to the database when it was suppose to throw an exception.

I need your help to figure out this problem.

Thanks.
Oh and I'm new in the forum. i think i can help you with some problems too.

Re: Disconnected Mode

Posted: Wed 12 Sep 2007 20:24
by eduardosic
PoSeiDoN31 wrote:Hi I've been working with MyDac and I've created an application connecting to MySql. I'm working with disconnected mode and pooling, but i was testing some problems and i completely disconnect the TMyConnection component, this means, that i set the properties:
- Connected = false
- Disconnected Mode = false
- Pooling = false.
The problem is that when i open the TMyQuery component, it connects to the database when it was suppose to throw an exception.

I need your help to figure out this problem.

Thanks.
Oh and I'm new in the forum. i think i can help you with some problems too.
inform more details, what exception are raised?

Posted: Wed 12 Sep 2007 20:39
by PoSeiDoN31
The problem is that it doesn't throw the exception.
Let me explain better, i have a TMyConnection component pointing to a database and a TMyQuery component that calls a Stored Procedure.

I've set all the properties in the TMyConnection component to be disconnected like i explained in the last post. so that means that i shouldn't be able to execute the query. but when i call the open method of the query it automatically connects to the database and i don't think that is what should happen. i also have the property of the TMyQuery component named Create Connection set to False.

i don't understand why it connects and execute the query when everything is disconnected.

I'll appreciate your help

See mydac Help

Posted: Wed 12 Sep 2007 20:53
by eduardosic
PoSeiDoN31 wrote:The problem is that it doesn't throw the exception.
Let me explain better, i have a TMyConnection component pointing to a database and a TMyQuery component that calls a Stored Procedure.

I've set all the properties in the TMyConnection component to be disconnected like i explained in the last post. so that means that i shouldn't be able to execute the query. but when i call the open method of the query it automatically connects to the database and i don't think that is what should happen. i also have the property of the TMyQuery component named Create Connection set to False.

i don't understand why it connects and execute the query when everything is disconnected.

I'll appreciate your help
in MyDAC Help;;

In disconnected mode a connection opens only when it is required. After performing all server calls connection closes automatically until next server call is required. Datasets remain open when connection closes. Disconnected mode may be useful to save server resources and operate in unstable or expensive network. Drawback of using disconnected mode is that each connection establishing requires some time for authorization. If connection is often closed and opened it can slow down application work. We recommend to use pooling to solve this problem. For additional information see TCustomDAConnection.Pooling.

To enable disconnected mode set TCustomDAConnection.Options.DisconnectedMode to True.

In disconnected mode a connection is opened for executing requests to the server (if it was not already opened) and is closed automatically if it is not required any more. If the connection was explicitly opened (Connect method was called or Connected property was explicitly set to True), it does not close until Disconnect method will be called or Connected property will be explicitly set to False.

Disconnected mode features

If you perform a query with FetchAll option set to true, connection closes when all data are fetched if it is not used by someone else. If FetchAll option is set to false, connection does not close until all data blocks are fetched.

If explicit transaction is started, connection does not close until the transaction will be committed or rolled back.

If the query was prepared explicitly, connection does not close until the query will be unprepared or its SQL text will be changed.

Posted: Wed 12 Sep 2007 21:02
by PoSeiDoN31
i already read that. but the thing is that i have disconnected mode disabled. so that won't help me.

Thanks anyway

wait...

Posted: Wed 12 Sep 2007 21:08
by eduardosic
PoSeiDoN31 wrote:i already read that. but the thing is that i have disconnected mode disabled. so that won't help me.

Thanks anyway
We go to wait a better explanation of Antaeus.

certainly Antaeus goes to help you better.

Posted: Thu 13 Sep 2007 06:52
by Antaeus
When you try to open/execute a command with TMyQuery, and linked TMyConnection is closed, TMyQuery initiates connection automatically.
This is a designed behaviour. DisconnectedMode, Pooling, and CreateConnection options have no influence on it.

Posted: Thu 13 Sep 2007 12:07
by PoSeiDoN31
ok, thanks for solving my problem.
:D