Board index » delphi » Size limit at TQuery.SQL???

Size limit at TQuery.SQL???

Hallo together,

I have problems with my new application (Delphi 4.02)

It seems to be an problem with my TQuery components.
All works fine until I change the Property "SQL.Text".
I do a

MyQuery.SQL.Text := MyString; {Type "String"}

Then the Application crashes with an access violation error, for example
when calling
a Quickreport-Preview or when putting a New Record in any Table.
Any ideas??
Is the a size limitation on the TQuery.SQL.Text Property???? (MyString
ist about 500 Byte long)

Thanks
Andreas

 

Re:Size limit at TQuery.SQL???


On Wed, 14 Jul 1999 13:37:56 +0200, Andreas Vossloh

Quote
<serv...@vossloh-online.de> wrote:
>I have problems with my new application (Delphi 4.02)

>It seems to be an problem with my TQuery components.
>All works fine until I change the Property "SQL.Text".
>I do a

>MyQuery.SQL.Text := MyString; {Type "String"}

>Then the Application crashes with an access violation error, for example
>when calling
>a Quickreport-Preview or when putting a New Record in any Table.

>Any ideas??
>Is the a size limitation on the TQuery.SQL.Text Property???? (MyString
>ist about 500 Byte long)

If I am not mistaken, the individual string elements in a string list array
of strings must be a short string. That is, no longer than 255 characters.
But then you can break up an SQL statement (even when stored in a wide
string variable) into multiple lines using carriage-returns and line-feeds.
In the string variable, these formatting characters are just other
characters. It is not until the value is assigned to the string list object
that it is actually broken down into multiple lines.

Does the application crash if you simply store the string's value to the
TQuery.SQL property and then  activate the TQuery? An access violation is
not what I would associate with a too-long SQL statement. Rather, I would
expect the statement to be truncated in the SQL property, an invalid SQL
statement would then be sent to the database back-end, and then it would
raise an EDBEngineError over the invalid SQL.

Before activating the TQuery, try visually verifying the contents of the
TQuery.SQL property. One way to do that would be to display the contents of
the property using the ShowMessage procedure.

  ShowMessage(MyQuery.SQL.Text);

Assuming the contents are valid for an SQL statement and the exception is
not occurring due to the SQL itself, you would need to narrow down when the
error occurs. "Putting a new record in any table"?

Also, you give no indication of the database and how it is accessed. Is it
a local or SQL database? Accessed through a native BDE driver, ODBC driver,
alternative database engine, or ... ? And what is the component MyQuery? A
stock TQuery or a third-party component?

==========================================================================
Steve Koterski                  "Computers are useless. They can only give
Technical Publications          you answers."
Borland                                       -- Pablo Picasso (1881-1973)
http://www.borland.com/techpubs/delphi

Re:Size limit at TQuery.SQL???


Borland schrieb:

Quote
> On Wed, 14 Jul 1999 13:37:56 +0200, Andreas Vossloh
> <serv...@vossloh-online.de> wrote:

> >I have problems with my new application (Delphi 4.02)

> >It seems to be an problem with my TQuery components.
> >All works fine until I change the Property "SQL.Text".
> >I do a

> >MyQuery.SQL.Text := MyString; {Type "String"}

> >Then the Application crashes with an access violation error, for example
> >when calling
> >a Quickreport-Preview or when putting a New Record in any Table.

> >Any ideas??
> >Is the a size limitation on the TQuery.SQL.Text Property???? (MyString
> >ist about 500 Byte long)

> If I am not mistaken, the individual string elements in a string list array
> of strings must be a short string. That is, no longer than 255 characters.
> But then you can break up an SQL statement (even when stored in a wide
> string variable) into multiple lines using carriage-returns and line-feeds.
> In the string variable, these formatting characters are just other
> characters. It is not until the value is assigned to the string list object
> that it is actually broken down into multiple lines.

Well, I got this string-content by saving the Property SQL.Text into it to
preserve the original state of the SQL Statement before and then coping it
back.

I did this

var
  originalstring: string

....

originalstring := MyQuery.SQL.Text;

.... (do something with MYQuery...)

MyQuery.SQL.Text := originalstring;

(I tried the same with CommaText, it did not work, too)

Quote

> Does the application crash if you simply store the string's value to the
> TQuery.SQL property and then  activate the TQuery? An access violation is
> not what I would associate with a too-long SQL statement. Rather, I would
> expect the statement to be truncated in the SQL property, an invalid SQL
> statement would then be sent to the database back-end, and then it would
> raise an EDBEngineError over the invalid SQL.

The application crashes not, when I Open then Query, but later on during other
operations. It seems so as if some Memory locations are overwritten, or such
things.
I tried to save the SQL-Statement line wise in an Array of String[20] (the
maximum length of the Statement lines ist 20) and replaced it linewise by

for x := 1 to 15 do
  MyQuery.SQL.Strings[x] := BufferString[x]

This works now. But I am not sure. And I do not want my Customer to try out
whether it is working all then time :-)

Quote

> Before activating the TQuery, try visually verifying the contents of the
> TQuery.SQL property. One way to do that would be to display the contents of
> the property using the ShowMessage procedure.

>   ShowMessage(MyQuery.SQL.Text);

> Assuming the contents are valid for an SQL statement and the exception is
> not occurring due to the SQL itself, you would need to narrow down when the
> error occurs. "Putting a new record in any table"?

There are several occasions where the error occurs but it is difficult too
explain
Sure ist the following:

I produce a Quickreport unsing the same Database-File, it has its own
TTable-Component. I can preview the report until i change the SQL.Text
property.
Then then Application crashes at "MyQuery.Preview". It is a difference whether
I open the TQuery after changing it or not.

If I do then Application crashes immediatily on calling MyQuery.Preview.

if i do not open then TQuery the application crashes later or the whole Delpi
crashes! (especially if i try to close Delphi)

Quote

> Also, you give no indication of the database and how it is accessed. Is it
> a local or SQL database? Accessed through a native BDE driver, ODBC driver,
> alternative database engine, or ... ? And what is the component MyQuery? A
> stock TQuery or a third-party component?

I use Delphi 4.02 Standard (German) with Local SQL (of course :-) ) there is no
third-party component installed or used. I use the shipped-with Database-engine

Quote

Thanks, for help
Andreas

P.S.: May it helpful to send a short program demonstrating the error?
Where can I send it???

- Show quoted text -

Quote

> ==========================================================================
> Steve Koterski                  "Computers are useless. They can only give
> Technical Publications          you answers."
> Borland                                       -- Pablo Picasso (1881-1973)
> http://www.borland.com/techpubs/delphi

Other Threads