Solved

multiple TQuery.Open lockup problems in TThread

Posted on 1998-01-24
19
178 Views
Last Modified: 2010-04-04
Here is my story:

I wrote an application which
a) opens a query (which is placed on a form and is a simple select) on
the remote server, then closes it

FirstQuery.Open;
FirstQuery.Close;

b) creates a simple thread

TSimpleThread.Create;

c) the thread Create does this:

Query := TQuery.Create( MainForm );
Query.DatabaseName := 'database';
Inherited Create( False );

d) the thread Execute does this:

Query.SQL.Add( 'SELECT * FROM SOMETABLE' );
Query.Open;

Now at point d) the Query.Open just NEVER returns!!!

If I skip (comment out) a) it works just fine!
If I put c) and d) in the main thread it works just fine!
If I give nil or Application to TQuery.Create() instead of MainForm it
still hangs.
If I allocate the Query in d) it's hangs all the same. If I use a TTable
instead of FirstQuery it's all the same.
Once I somehow changed the program to hang even earlier on
Query.SQL.Add().
I tried to monitor the ODBC calls and the last ones I got was
PrepareStatement and ExecStatement or smth like that. Then you can just
wait for the results to be returned - forever.

So is it a problem with my thread creating or my query creating? Or is
it a BDE or an ODBC problem? Is it supposed to be that way?

I'm getting totally confused and desperate on this issue... :-(
Any ideas would be really appreciated.
0
Comment
Question by:juris
  • 11
  • 8
19 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1357439
Or you using MSAccess tables?
0
 

Author Comment

by:juris
ID: 1357440
No, a remote RDBMS server.

0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1357441
sorry, then I can't help you, found on borland site an article about problems with access and threading queries.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 8

Expert Comment

by:ZifNab
ID: 1357442
found another article, maybe it helps :

http://www.borland.com/devsupport/delphi/ti_list/TI3005.html
0
 

Author Comment

by:juris
ID: 1357443
Hey, ZifNab, thanks, I'll read it and see if it helps but this sure looks good.

If you want, you can post the URL as an answer and I will grade you ASA as I get my code running!

:-)

Looks like you made my day better.

0
 
LVL 8

Accepted Solution

by:
ZifNab earned 40 total points
ID: 1357444
Yo may reduce the points if you grade my answer to this question :

found another article, maybe it helps :                              http://www.borland.com/devsupport/delphi/ti_list/TI3005.html

Hope it works, let me know if so!

Regards,
Zif.
0
 

Author Comment

by:juris
ID: 1357445
Yeah, that really works.

Thanks again!

BTW I have another problem.

When ExecSQL-ing a simple 'DELETE FROM TABLENAME' query I get a 'table is read only' BDE error :-(. I tried both with RequestLive of True and False and it still wouldn't work.

0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1357446
Strange, I'll look after it.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1357447
Sorry for the delay.
How to you call this ExecSQL? :

Like this way? :

 Query1.Prepare;
 Query1.Params[0] := '.........'; {if you use parameters}
 Query1.ExecSQL;
 Query1.Refresh;

If not, try it this way and let me know.
0
 

Author Comment

by:juris
ID: 1357448
Didn't work that way too.
Right now I am selecting and then .Delete-ing... It works, although might be slower...



0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1357449
where did it go wrong?
0
 

Author Comment

by:juris
ID: 1357450
On Prepare;. SQL statement empty.

0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1357451
And you had declared a SQL ?
0
 

Author Comment

by:juris
ID: 1357452
What do you mean - declared?
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1357453
You're quick:
Well, in Query.SQL := 'delete ....'
0
 

Author Comment

by:juris
ID: 1357454
OK, sorry, commented that out.
It goes wrong on ExecSQL telling that 'Table is read only'.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1357455
I see my comment can be misinterpreted. With 'You're quick' I mean that you were quick with responding to my answer. Sorry if you thought of something else.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1357456
Strange. Then I can't help you for the moment. Sorry.
0
 

Author Comment

by:juris
ID: 1357457
Come on, that's OK. I know what you meant.
Although I admit it *was* stupid to comment the SQL assignment out. :-).
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question