Subject | Re: [IBO] Multi threaded access using in objects |
---|---|
Author | Helen Borrie |
Post date | 2004-06-28T13:16:32Z |
At 12:02 PM 28/06/2004 +0000, you wrote:
owners for anything but the TIB_Session.
FConnection := TIB_Connection.Create(FSession);
FQuery := TIB_Query.Create(FSession);
FQuery.IB_Transaction := FConnection.ib_transaction;
or, better, declare an explicit IB_Transaction (FTransaction :=
TIB_Transaction.Create(FSession);
FTransaction.[..........properties...........]
FTransaction.IB_Connection := FConnection;
then
FQuery.IB_Transaction := FConnection;
FConnection.Path := 'c:\test.gdb';
(DatabaseName would be '127.0.0.1:c:\test.gdb' but IBO doesn't need it)
with FQuery do
begin
if not IB_Transaction.Started then
ib_Transaction.StartTransaction;
SQL.Add('a statement');
if not Prepared then Prepare;
Params[n].AsWhatever := something;
...
Execute;
end;
What are you executing? TIB_Query is for SELECT statements. Use
TIB_Cursor or TIB_DSQL for executable statements.
Helen
>I have seen some posts on this subject.Don't use CreateForSession: it has another purpose. And don't use nil
>1. I need an explisit session.
>2. prorocol : cpTCP_IP
>3. Server : 127.0.0.1
>
>This code is inside the constructor of the thread. What is missing
>please.
>
> FSession := TIB_Session.Create(nil);
> FConnection := TIB_Connection.CreateForSession(nil,FSession);
owners for anything but the TIB_Session.
FConnection := TIB_Connection.Create(FSession);
> FConnection.Protocol := cpTCP_IP;not
> FConnection.Server := '127.0.0.1';
> FQuery := TIB_Query.CreateForSession(nil,FSession);but
FQuery := TIB_Query.Create(FSession);
> FQuery.IB_Connection := FConnection;Either
FQuery.IB_Transaction := FConnection.ib_transaction;
or, better, declare an explicit IB_Transaction (FTransaction :=
TIB_Transaction.Create(FSession);
FTransaction.[..........properties...........]
FTransaction.IB_Connection := FConnection;
then
FQuery.IB_Transaction := FConnection;
> FConnection.DatabaseName := 'c:\test.gdb';Wrong here. You want
FConnection.Path := 'c:\test.gdb';
(DatabaseName would be '127.0.0.1:c:\test.gdb' but IBO doesn't need it)
> FConnection.Username := 'SYSDBA';Something is missing here:
> FConnection.Password := 'masterkey';
> FConnection.Connect;
>
>The thread breaks on the fquery.execute line.
with FQuery do
begin
if not IB_Transaction.Started then
ib_Transaction.StartTransaction;
SQL.Add('a statement');
if not Prepared then Prepare;
Params[n].AsWhatever := something;
...
Execute;
end;
What are you executing? TIB_Query is for SELECT statements. Use
TIB_Cursor or TIB_DSQL for executable statements.
>When I create only one thread the code works fine.What happens when subsequent threads run?
Helen