Solved

multiple TQuery.Open lockup problems in TThread

Posted on 1998-01-24
19
183 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Convert a string into a TDateTime 5 80
can't find the executable in Simulator 1 130
Delphi: barcode reading on android platform 1 100
migrate this code to work on android 1 45
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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

734 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