Solved

multiple TQuery.Open lockup problems in TThread

Posted on 1998-01-24
19
169 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
 
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Thread safe  opinion 7 111
Correct Component for Shopping Cart. 2 85
LAN or WAN ? 11 61
Base1 Encode/Decode 3 31
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now