Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

multiple TQuery.Open lockup problems in TThread

Posted on 1998-01-24
19
Medium Priority
?
185 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

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.

Question has a verified solution.

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

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

721 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