Subject RE: [IBO] Thread Error - Bug
Author Jason Wharton
I'm still not understanding the nature of the problem.
Can you break it down into greater detail?

Jason

-----Original Message-----
From: Vincenzo Scarpellino [mailto:vincenzoscarpellino@...]
Sent: Wednesday, September 01, 2004 2:17 AM
To: IBObjects Support
Subject: Re: [IBO] Thread Error - Bug


When I click on button to perform Thread Query and I don't wait until it
ends so I follow a new query and the result is that the first query remains
suspended (so as it was waiting), while the second query works fine.

Thank You
Best Regards
----- Original Message -----
From: Jason Wharton
To: IBObjects@yahoogroups.com
Sent: Tuesday, August 31, 2004 9:58 PM
Subject: RE: [IBO] Thread Error - Bug


As a side note:

This code is not correct.

if not IB_Transaction.Started then
IB_Transaction.StartTransaction;

The Started property has to do with the physical transaction handle being
present. The StartTransaction method has purely to do with an explicit
(programmer's context only) aspect of transactions.

You should either write it like this:

if not IB_Transaction.InTransaction then
IB_Transaction.StartTransaction;

Or, you should simply delete that code and allow a physical transaction to
be started when appropriate automatically.

Your description of your problem needs to be more clear. I don't know
exactly what you mean by "hangs".

Jason Wharton

-----Original Message-----
From: Vincenzo Scarpellino [mailto:vincenzoscarpellino@...]
Sent: Monday, August 30, 2004 3:31 AM
To: IBObjects@yahoogroups.com
Subject: [IBO] Thread Error - Bug



FB 1.5 - IBO 4.3.Aa - WIN XP Prof.


Hi,

Before my holiday I wrote any messages about to execute a query in
background with TThread Object, but I didn't understand if my problems
depends by a bug or an wrong error using IBObjects. I am converting my BDE
application and I am trying to get the same behavior with run a query in
background. It work fine when I let elapse a little time before to run a
new
query: I have a button to run my query (see borland demos in
delphi7\demos\db\BkQuery I am using that sample of course changing
reference
objects) when I click without let elapse this time first query hangs and
second work fine. Next there is my code (I tried to use IB_Cursor or
IB_Query with IB_Grid with IB_Datasource but nothing changed). Why doesn't
it work fine ? Is it a bug ?


type
TForm2 = class(TForm)
DBGrid1: TDBGrid;
Navigator1: TDBNavigator;
DSThread: TDataSource;
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form2: TForm2;

{ TEurSecurityThread }
type
TEurSecurityThread = class(TThread)
private
FSession:TIB_Session;
FConnection: TIB_Connection;
FTransaction: TIB_Transaction;
FQuery: TIBOQuery;
procedure ConnectQuery;
protected
procedure Execute; override;
public
constructor Create(QForm:TForm2);
end;

procedure BackgroundQuery;

implementation

{$R *.dfm}

{ BackgroundQuery }
procedure BackgroundQuery;
begin
Form2 := TForm2.Create(Application);

with Form2 do
begin
Show;
end;

TEurSecurityThread.Create(Form2);
end;

constructor TEurSecurityThread.Create(QForm:TForm2);
begin
Form2 := QForm;
FreeOnTerminate := True;
inherited Create(False);
end;

procedure TEurSecurityThread.ConnectQuery;
begin
with Form2 do
begin
DSThread.DataSet:= FQuery;
DBGrid1.DataSource:= DSThread;
Navigator1.DataSource:= DSThread;

WindowState:= wsNormal;
BringToFront;
end;
end;

procedure TEurSecurityThread.Execute;
begin
with Form2 do
try
try
if (FSession = nil) then
begin
FSession := TIB_Session.Create(nil);

FConnection:= TIB_Connection.Create(FSession);

FConnection.Protocol:= cpTCP_IP;
FConnection.Server:= '192.168.255.2';
FConnection.Path:= 'C:\EURARCHI\DATABASE';
FConnection.SQLDialect:= 3;
FConnection.Username:= 'SYSDBA';
FConnection.Password:= 'masterkey';

FTransaction:= TIB_Transaction.Create(FSession);
FTransaction.IB_Connection:= FConnection;

FQuery:= TIBOQuery.Create(FSession);
FQuery.IB_Transaction:= FTransaction;
FQuery.IB_Connection:= FConnection;


with FQuery do
begin
if not IB_Transaction.Started then
IB_Transaction.StartTransaction;

FQuery.SQL.Clear;
FQuery.SQL.Add('SELECT * FROM CLF WHERE EURAZNOME= ''GRP''');

if not Prepared then Prepare;
Open;
end;
end;

Synchronize(ConnectQuery);
except
WindowState:= wsNormal;
end;
finally
WindowState:= wsNormal;
end;
end;

end.








___________________________________________________________________________
IB Objects - direct, complete, custom connectivity to Firebird or
InterBase
without the need for BDE, ODBC or any other layer.

___________________________________________________________________________
http://www.ibobjects.com - your IBO community resource for Tech Info
papers,
keyword-searchable FAQ, community code contributions and more !


Yahoo! Groups Sponsor
ADVERTISEMENT





----------------------------------------------------------------------------
--
Yahoo! Groups Links

a.. To visit your group on the web, go to:
http://groups.yahoo.com/group/IBObjects/

b.. To unsubscribe from this group, send an email to:
IBObjects-unsubscribe@yahoogroups.com

c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.




--
Email.it, the professional e-mail, gratis per te: http://www.email.it/f

Sponsor:
Pratico schermo anti-riflesso. Ripara e mantiene completa visione della
strada
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid$13&d=1-9

[Non-text portions of this message have been removed]




___________________________________________________________________________
IB Objects - direct, complete, custom connectivity to Firebird or InterBase
without the need for BDE, ODBC or any other layer.
___________________________________________________________________________
http://www.ibobjects.com - your IBO community resource for Tech Info papers,
keyword-searchable FAQ, community code contributions and more !
Yahoo! Groups Links