Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Reconnection problems with AnyDAC on PhysLayer

453 views
Skip to first unread message

Martin Brandt

unread,
Aug 23, 2005, 6:24:42 AM8/23/05
to
Hello
i am currently evaluating the AnyDAC Functionality on Phys Layer and it
seems like i can not connect more than once to an Access-DB. In the first
run all seems right, but executing the method again, I get an
EAccessViolation. This seems to result from setting oCmd and oConn to Nil,
but not doing so, i get on calling ADPhysManager.Close(True) an
'ADPhysManager Shutdown timeout. Possible Reason: Application has not
released all connection interfaces'. What am I doing wrong? Could anybody
please help me?

procedure TForm1.Button1Click(Sender: TObject);
Var oConn : IADPhysConnection;
oCmd : IADPhysCommand;
oTab : TADDatSTable;
i, j : Integer;
s : String;
begin
// 1. open AnyDAC's ADPhysManager
ADPhysManager.Open;
With ADPhysManager.ConnectionDefs.AddConnectionDef Do
Begin
Name := 'My_DB';
DriverID := 'MSAcc';
Database := '.\db\Test.mdb';
Params.Add ('Tracing=True');
End;

// 2. create connection
ADPhysManager.CreateConnection('My_DB', oConn);
oConn.Open;

// 3. create command and prepare SELECT statement
oConn.CreateCommand(oCmd);
oCmd.Prepare('select str_Kuenstler from tbl_Kuenstler');
oCmd.Open;

// 4. fetch rows from RDBMS to DatSTable
oTab := TADDatSTable.Create;
oCmd.Define (oTab);
oCmd.Fetch (oTab);

// 5. print rows
Memo1.Clear;
for i := 0 to oTab.Rows.Count - 1 Do
Begin
s := '';
for j := 0 To oTab.Columns.Count - 1 Do
s := s + oTab.Rows[I].GetData(J) + ' ';
Memo1.Lines.Add(s);
end;

// 6. free resources
oCmd.Unprepare;
oCmd.Close;

oConn.Close;

oTab.Free;
oConn := Nil;
oCmd := Nil;

ADPhysManager.Close(True);
end;


Dmitry Arefiev [gs-soft.ru]

unread,
Aug 23, 2005, 8:06:49 AM8/23/05
to
Hello Martin !

I have just asked to you at my site.

1) I have just checked your demo with AnyDAC v 1.2.5 and
I does not see any issues. Could you download v 1.2.5 and try
again, please ? Then, please, let me know the result.

2) Also, you can replace:


> // 6. free resources
> oCmd.Unprepare;
> oCmd.Close;
>
> oConn.Close;
>
> oTab.Free;
> oConn := Nil;
> oCmd := Nil;
>
> ADPhysManager.Close(True);

with:

// 6. free resources
oTab.Free;
ADPhysManager.Close(False);

That means, Delphi runtime will wipe out unused interfaces
for you. And Close(False) will close manager right after all
connection interfaces will be released, but not blocking caller
until that moment.

Regards,
Dmitry

--
Dmitry Arefiev - www.da-soft.com
AnyDAC - Oracle, MySQL, MSSQL, MSAccess, IBM DB2, Sybase
ASA, DbExpress, ODBC freeware data access framework
gs-soft AG - www.gs-soft.com
SAPx - Delphi to SAP R/3 direct access
Saphir - SAP R/3 metadata at your fingertips
MetaBase - ERWIN model in Delphi applications


Dmitry Arefiev [gs-soft.ru]

unread,
Aug 23, 2005, 8:14:30 AM8/23/05
to
Also, you dont need to Open/Close phys manager on each
button click. I will suggest to put:
- addition of connection definition and phys manager open
at form OnCreate;
- and remove ADPhysManager.Close call at all. AnyDAC
will do that for you.
Message has been deleted
0 new messages