| View previous topic :: View next topic |
| Author |
Message |
Isaac Alexander Guest
|
Posted: Wed Apr 06, 2005 6:51 pm Post subject: TQuery Access Violations |
|
|
I am using D7.1, BDE 5.2.0.2, ODBC, and MS SQL Server 2000. Switching away
from the BDE is not possible at the moment (3000+ queries).
I am getting access violations when opening multiple TQuery components (more
than 5 and less than 10).
There doesn't seem to be a set number that causes the error. I have checked
by commenting out a query here and a query there and the error goes away. It
isn't specific to any query.
I added FetchAll after the open of all queries hoping that it would help (no
luck).
The majority of the queries are not attached to grids. They are opened,
recursed then closed.
I noticed that it may have something to do with using the Filter property.
Has anyone else encountered this problem? What is the "real" technical
reason for the error? I can work around it, but it is pain to change the
logic to accommodate a "bug" in the BDE/Delphi.
Any comments and/or suggestions would be great.
|
|
| Back to top |
|
 |
Wayne Niddery [TeamB] Guest
|
Posted: Wed Apr 06, 2005 7:07 pm Post subject: Re: TQuery Access Violations |
|
|
Isaac Alexander wrote:
| Quote: |
I am getting access violations when opening multiple TQuery
components (more than 5 and less than 10).
There doesn't seem to be a set number that causes the error. I have
checked by commenting out a query here and a query there and the
error goes away. It isn't specific to any query.
I noticed that it may have something to do with using the Filter
property.
Has anyone else encountered this problem? What is the "real" technical
reason for the error? I can work around it, but it is pain to change
the logic to accommodate a "bug" in the BDE/Delphi.
|
I've never seen such a problem. My best guess is that you may be
experiencing a memory problem of some sort (i.e. running out). You indicate
3000+ queries, I assume these are spread over a large number of forms and/or
datamodules. What percentage of these are auto-created when the app starts?
If you create these (all or most) in code only when actually needed (instead
of auto-creating), do you also close them when done or are they left open?
--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
"The only reason some people get lost in thought is because it's
unfamiliar territory." - Paul Fix
|
|
| Back to top |
|
 |
Isaac Alexander Guest
|
Posted: Wed Apr 06, 2005 8:29 pm Post subject: Re: TQuery Access Violations |
|
|
| Quote: | I've never seen such a problem.
|
I saw it a long time ago (2-3 years and D5) when I used multiple dynamically
created TQuery components. It would actually shut down the application. I
changed the logic to have only one query open at a time since I didnt need
to show any results until the end.
| Quote: | My best guess is that you may be
experiencing a memory problem of some sort (i.e. running out). You
indicate
3000+ queries, I assume these are spread over a large number of forms
and/or
datamodules.
|
Yes. The queries are spread across the different forms (no datamodules other
than the TDatabase one). There are only 10 queries on this form (only 3 are
active at the time of the access violation). There are around 10 queries
active for the entire application at the time of the error.
What percentage of these are auto-created when the app starts?
| Quote: | If you create these (all or most) in code only when actually needed
(instead
of auto-creating), do you also close them when done or are they left open?
|
None of the queries are created in code. I tried both ways and when the
queries were created in code, I received the error more often. All of the
queries are separate TQuery components on the form.
I close each query once I have finished cycling through it. The error occurs
on the open of the next query.
|
|
| Back to top |
|
 |
Wayne Niddery [TeamB] Guest
|
Posted: Thu Apr 07, 2005 2:55 pm Post subject: Re: TQuery Access Violations |
|
|
Isaac Alexander wrote:
| Quote: |
What percentage of these are auto-created when the app starts?
If you create these (all or most) in code only when actually needed
(instead of auto-creating), do you also close them when done or are
they left open?
None of the queries are created in code. I tried both ways and when
the queries were created in code, I received the error more often.
All of the queries are separate TQuery components on the form.
I close each query once I have finished cycling through it. The error
occurs on the open of the next query.
|
How many forms are open though?
Are you using any threads?
--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
Those who disdain wealth as a worthy goal for an individual or a
society seem not to realize that wealth is the only thing that can
prevent poverty. - Thomas Sowell
|
|
| Back to top |
|
 |
Isaac Alexander Guest
|
Posted: Thu Apr 07, 2005 3:19 pm Post subject: Re: TQuery Access Violations |
|
|
| Quote: |
How many forms are open though?
|
Three. Main form, and two non-modal forms.
| Quote: |
Are you using any threads?
|
No. I am not creating any threads manually.
After some more testing, when I encounter the problem in the IDE, I get a
bunch of access violations (never-ending). If not running in the IDE, the
app just exits without calling any of the three forms' OnClose events.
|
|
| Back to top |
|
 |
Isaac Alexander Guest
|
Posted: Thu Apr 07, 2005 7:00 pm Post subject: Re: TQuery Access Violations |
|
|
| Quote: |
Have you been able to navigate to the statement corresponding to the first
AV?
|
Yes. It dies on the close of one of the two querys. I took away the local
filtering and dataset recursing and the error still occurs. I just open and
close the queries. It happens by simply doing the following:
Query1.SQL.Text := 'select something from something';
Query1.Open;
Query2.SQL.Text := 'select somethingelse from somethingelse';
Query2.Open;
Query2.Close;
Query1.Close; // endless access violations and app termination
The error occurs regardless of order of opening and closing providing that
they are both open at the same time. Example: Opening Query1 or Query2 first
and/or closing Query1 and/or Query2 first . It always fails on the second
close (Query1 or Query2)
The following code works but I need to have both open at the same time.
Query1.SQL.Text := 'select something from something';
Query1.Open;
Query1.Close;
Query2.SQL.Text := 'select somethingelse from somethingelse';
Query2.Open;
Query2.Close;
| Quote: | Still seems like there has to be something else contributing to the
problem.
I have one project (started way back in Delphi 4, migrated through D5 and
D6
since) on about the same scale as yours - 1000s of TQuery components (in
my
case spread across ~150 datamodules), and a few other projects somewhat
smaller but still with lots of queries, and I've never encountered this
*except* in the case of using threads.
|
I am in the same situation. I upgraded from D3 => D5 => D7. The form
getting the error is brand new.
| Quote: |
I wish I could think of something more to suggest, but I don't know of any
actual problems in the BDE/components that should cause this.
|
Too bad. It looks like I have found a reason to use my Software Assurance.
|
|
| Back to top |
|
 |
Wayne Niddery [TeamB] Guest
|
Posted: Fri Apr 08, 2005 2:56 am Post subject: Re: TQuery Access Violations |
|
|
Isaac Alexander wrote:
| Quote: |
Yes. It dies on the close of one of the two querys. I took away the
local filtering and dataset recursing and the error still occurs. I
just open and close the queries. It happens by simply doing the
following:
Query1.SQL.Text := 'select something from something';
Query1.Open;
Query2.SQL.Text := 'select somethingelse from somethingelse';
Query2.Open;
Query2.Close;
Query1.Close; // endless access violations and app termination
|
This, quite simply, should not happen. Can you create a test app that can
reproduce the problem? If so then I'd be willing to look at it. There *has*
to be some other reason for the problem - some other code upsetting the app
and the closing of the query is just triggering the "timebomb".
Unfortunately, the culprit could literally be anywhere.
--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
"A man is likely to mind his own business when it is worth minding,
when it is not, he takes his mind off his own meaningless affairs by
minding other people's business." - Eric Hoffer
|
|
| Back to top |
|
 |
Barak zabari Guest
|
Posted: Fri Apr 08, 2005 12:00 pm Post subject: Re: TQuery Access Violations |
|
|
Do you have lookup field in the query ?
"Isaac Alexander" <isaaNOSPAMc (AT) goproNOSPAMcura (DOT) com> wrote
| Quote: |
Have you been able to navigate to the statement corresponding to the
first
AV?
Yes. It dies on the close of one of the two querys. I took away the local
filtering and dataset recursing and the error still occurs. I just open
and
close the queries. It happens by simply doing the following:
Query1.SQL.Text := 'select something from something';
Query1.Open;
Query2.SQL.Text := 'select somethingelse from somethingelse';
Query2.Open;
Query2.Close;
Query1.Close; // endless access violations and app termination
The error occurs regardless of order of opening and closing providing that
they are both open at the same time. Example: Opening Query1 or Query2
first
and/or closing Query1 and/or Query2 first . It always fails on the second
close (Query1 or Query2)
The following code works but I need to have both open at the same time.
Query1.SQL.Text := 'select something from something';
Query1.Open;
Query1.Close;
Query2.SQL.Text := 'select somethingelse from somethingelse';
Query2.Open;
Query2.Close;
Still seems like there has to be something else contributing to the
problem.
I have one project (started way back in Delphi 4, migrated through D5
and
D6
since) on about the same scale as yours - 1000s of TQuery components (in
my
case spread across ~150 datamodules), and a few other projects somewhat
smaller but still with lots of queries, and I've never encountered this
*except* in the case of using threads.
I am in the same situation. I upgraded from D3 => D5 => D7. The form
getting the error is brand new.
I wish I could think of something more to suggest, but I don't know of
any
actual problems in the BDE/components that should cause this.
Too bad. It looks like I have found a reason to use my Software Assurance.
|
|
|
| Back to top |
|
 |
Isaac Alexander Guest
|
Posted: Fri Apr 08, 2005 3:51 pm Post subject: Re: TQuery Access Violations |
|
|
"Barak zabari" <lotemlotad (AT) yahoo (DOT) com> wrote
| Quote: | Do you have lookup field in the query ?
|
Not in the queries being opened and closed, but the main query is displayed
in a grid (TwwDBGrid/Infopower) using a TQuery and TClientDataSet. The main
query grid does have a lookup attached to it.
Some background... the main grid shows records that get checked for business
rules using the "crashing" queries. I update a field in the main grid to
show the results. Users have a lookup/dropdown to state which action they
would like to perform on each record.
Are there issues with having a lookup in a grid? I have used this approach
in other areas too.
|
|
| Back to top |
|
 |
Isaac Alexander Guest
|
Posted: Fri Apr 08, 2005 4:35 pm Post subject: Re: TQuery Access Violations |
|
|
"Wayne Niddery [TeamB]" <wniddery (AT) chaffaci (DOT) on.ca> wrote
| Quote: |
This, quite simply, should not happen. Can you create a test app that can
reproduce the problem?
|
I wish I could.
| Quote: | If so then I'd be willing to look at it. There *has*
to be some other reason for the problem - some other code upsetting the
app
and the closing of the query is just triggering the "timebomb".
Unfortunately, the culprit could literally be anywhere.
|
I was afraid of that. I ran it through SQL Monitor and all queries are
firing correctly. I also ran it through AQTime 4 and no memory leaks. I have
a case open with Borland so hopefully they can enlighten me.
|
|
| Back to top |
|
 |
Barak zabari Guest
|
Posted: Tue Apr 12, 2005 11:29 am Post subject: Re: TQuery Access Violations |
|
|
Sorry for the late replay
In certain setting i got errors when i had lookup fields unless i set the
lookup field
LookUpCache :=True;
It took me a long time to find out that in certain cases i get this error a
few times only when i have lookup fields that did got set to cache and since
my help table are more or less static i decide to not work even more trying
to guess why this happen but just take the easy way out and set it up that
way.
"Isaac Alexander" <isaaNOSPAMc (AT) goproNOSPAMcura (DOT) com> wrote
| Quote: | "Barak zabari" <lotemlotad (AT) yahoo (DOT) com> wrote in message
news:42566425$1 (AT) newsgroups (DOT) borland.com...
Do you have lookup field in the query ?
Not in the queries being opened and closed, but the main query is
displayed
in a grid (TwwDBGrid/Infopower) using a TQuery and TClientDataSet. The
main
query grid does have a lookup attached to it.
Some background... the main grid shows records that get checked for
business
rules using the "crashing" queries. I update a field in the main grid to
show the results. Users have a lookup/dropdown to state which action they
would like to perform on each record.
Are there issues with having a lookup in a grid? I have used this
approach
in other areas too.
|
|
|
| Back to top |
|
 |
Isaac Alexander Guest
|
Posted: Tue Apr 12, 2005 9:04 pm Post subject: Re: TQuery Access Violations |
|
|
"Barak zabari" <lotemlotad (AT) yahoo (DOT) com> wrote
| Quote: | Sorry for the late replay
|
No problem.
| Quote: | In certain setting i got errors when i had lookup fields unless i set the
lookup field
LookUpCache :=True;
It took me a long time to find out that in certain cases i get this error
a
few times only when i have lookup fields that did got set to cache and
since
my help table are more or less static i decide to not work even more
trying
to guess why this happen but just take the easy way out and set it up that
way.
|
I found the error. I opened a case with Borland, so I wanted to hear what
they said before I posted anything. It occurs when manually preparing an
insert query, executing it, then opening more than one query before
unpreparing the insert query. I sent them a simple app that accesses the MS
SQL Server pubs database. I will update the post once Borland gets back to
me.
|
|
| Back to top |
|
 |
|