Board index » delphi » Query longer than 255 chars

Query longer than 255 chars

Throught MailMerge of WordDocument object I tried to link to a Access 97
database (using OBDC).  I Used "OpenDataSource" function with last parameter
set with the SQL of my query. The problem is that my query string is longer
than 255 chars and generates an error!
How can i skip this?
Otherwise is there a method to use a parametric query defined directly
inside database (Storedprocedure) ?
 

Re:Query longer than 255 chars


  Instead of setting SQL.Text to your entire query string, break the string
into parts and call SQL.Clear (once) and then SQL.Add for each part of the
string.  That breaks it up into different lines and removes the problem of
the 255-char line limit.

  For example, instead of:
SQL.Text := 'SELECT a bunch of fields FROM a table WHERE a bunch of
conditions';
  Use:
SQL.Clear;
SQL.Add( 'SELECT a bunch of fields ' );
SQL.Add( ' FROM a table ' );
SQL.Add( ' WHERE a bunch of conditions ' );

-Howard

Re:Query longer than 255 chars


Thank you for your help but my problem still exists.
I tried to split my query string into last two parameters (I guess this was
your suggestion) but this time the error message is "Word was unable to open
the data source"; for sure it can't join and understand the splitted query.
I also had a quick read to the article but it seems to be about
Office2000(it suggests to install
SR-1) while i'm using Word 97.

"Deborah Pate (TeamB)" <d.p...@cableinet.co.not-this-bit.uk> ha scritto nel
messaggio news:VA.00000672.00099f63@cableinet.co.not-this-bit.uk...

Quote
> <<Orlati Andrea:
> The problem is that my query string is longer than 255
> chars and generates an error!

> The two last parameters of OpenDataSource are SQLStatement
> and SQLStatement1 - you use SQLStatement1 if your statement
> is too long for SQLStatement. There is a known problem with
> MSQuery, though, if you're using that:
> http://support.microsoft.com/support/kb/articles/q224/0/56.
> asp

> --
> Deborah Pate (TeamB) http://delphi-jedi.org

>   Use Borland servers; TeamB don't see posts via ISPs
>   http://www.borland.com/newsgroups/genl_faqs.html

Re:Query longer than 255 chars


<<Orlati Andrea:
The problem is that my query string is longer than 255
chars and generates an error!

Quote

The two last parameters of OpenDataSource are SQLStatement
and SQLStatement1 - you use SQLStatement1 if your statement
is too long for SQLStatement. There is a known problem with
MSQuery, though, if you're using that:
http://support.microsoft.com/support/kb/articles/q224/0/56.
asp

--
Deborah Pate (TeamB) http://delphi-jedi.org

  Use Borland servers; TeamB don't see posts via ISPs
  http://www.borland.com/newsgroups/genl_faqs.html

Re:Query longer than 255 chars


<<Orlati Andrea:
"Word was unable to open the data source"; for sure it
can't join and understand the splitted query.

Quote

OK, I've never dealt with a query that big. Can you record
a Word macro of yourself setting it up manually, and show
us the resulting VBA?

--
Deborah Pate (TeamB) http://delphi-jedi.org

  Use Borland servers; TeamB don't see posts via ISPs
  http://www.borland.com/newsgroups/genl_faqs.html

Other Threads