I have a Datamodule.
On this DM, there is several MyQuery comps and one MyConnection comp.
The MyConnection Pooling option is set to true.
I open all the myquery comps into a thread.
For each thread, I create a new MyConnection. The created MyConnection has the same options / properties (except his name) as the one defined in the DM.
Code: Select all
fMyConnection:=TMyConnection.Create(nil) ;
with fMyConnection do
Begin
loginprompt:=false;
pooling:= TCustomMyDataSet(FDataset).Connection.pooling;
PoolingOptions := TCustomMyDataSet(FDataset).Connection.PoolingOptions;
Server := TCustomMyDataSet(FDataset).Connection.Server;
Username := TCustomMyDataSet(FDataset).Connection.Username;
Password := TCustomMyDataSet(FDataset).Connection.Password;
Database := TCustomMyDataSet(FDataset).Connection.Database;
IsolationLevel := TCustomMyDataSet(FDataset).Connection.IsolationLevel;
Port := TCustomMyDataSet(FDataset).Connection.Port;
ConnectionTimeout := TCustomMyDataSet(FDataset).Connection.ConnectionTimeout;
options := TCustomMyDataSet(FDataset).Connection.options;
fMyDefaultConnection :=TCustomMyDataSet(FDataset).Connection;
End;
TCustomMyDataSet(FDataset).Connection:=fMyConnection;
Data are correctly loaded.
But when I want to disconnect from the MySQL server, my queries opened via m threads are not closed ! They have they proper Myconnection object !
So I'm no more able to close them. I tried to replace the thread MyConnection object with the DM MyConnection object. This only close my query.
Code: Select all
TCustomMyDataSet(FDataset).Connection:=fMyDefaultConnection;Thanks