Additional
dbCAP
AnyDAC
ThinDAC
NCOCI8
Topic: How to set Connection Pooling in runtime?
How to set Connection Pooling in runtime?
Posted: 2007/08/01 04:31
 
Hello!

How to set ConnectionPooling in runtime without to use a Connection definition (definition setup in AnyDAC Explorer)?
When i'm setup connection definition with this params:

  ================================ Connection definition parameters ================================ Database=someDB User_Name=sa Password=some_password AllowReconnect=True Server=some_server MetaDefSchema=dbo MetaDefCatalog=some_catalog DriverID=MSSQL2000 Pooled=True Encrypt=No Name=DEV2K


everything works fine!

When i setup connection in runtime:

    with ADConnection do   begin     Close;     Params.Clear;     Params.Add('Database=some_db');     Params.Add('User_Name=sa');     Params.Add('Password=some_password');     Params.Add('AllowReconnect=True');     Params.Add('Server=some_server');     Params.Add('MetaDefSchema=dbo');     Params.Add('MetaDefCatalog=some_catalog');     Params.Add('DriverID=MSSQL2000');     Params.Add('Pooled=True');     Params.Add('Encrypt=No');     Params.Add('Name=SomeConnName');     Open;   end;


I got this exception:
[AnyDAC][Comp][Clnt]-507. Connection cannot be pooled.
Possible reason: either it is not named, either has additional params.

Why? What's wrong with this code?

Best regards!
Re:How to set Connection Pooling in runtime?
Posted: 2007/08/01 04:41
 
Hello

1) You should do:
- create connection definition using ADManager. See DEMOComp LayerTADConnectionConnectionDefs for details. For example TfrmConnectionDefinitions.btnTestConn1Click.
- set ADConnection.ConnectionDefName to name of just created connction definition.

2) IOW, connection definition must be owned by ADManager. Without that AnyDAC will fail. Looks like text in "Possible reason" is not well ...

Regards,
Dmitry
Re:How to set Connection Pooling in runtime?
Posted: 2007/08/01 05:05
 
Hello again
It's works perfectly, thanks Diman!

Best regards.