Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

multiple TQuery.Open lockup problems in TThread

Posted on 1998-01-24
19
Medium Priority
?
187 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 160 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

Technology Partners: 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

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…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Integration Management Part 2
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

885 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