ADO Query String greater than 1024

Johannes_NielsenJohannes_Nielsen Member Posts: 206
This took me some time to get right and just wanted to share it with anyone searching for 1024 and ADO SQL query/connection strings.

The problem is the same as here:
http://www.mibuso.com/forum/viewtopic.php?t=11523

This put me on the right track
http://www.mibuso.com/forum/viewtopic.php?f=23&t=14429&start=0


If you want to query for alot of fields and hit the pre2013 limit of 1024 chars, then simply split the whole query and concatenate the less-than-1024-strings as arguments for the ADO Exectute method.
Like this:
lQuery1 := 'SELECT '+
  '[No_],[Sell-to Customer No_],[Bill-to Customer No_],[Bill-to Name],[Bill-to Name 2],[Bill-to Address],[Bill-to Address 2],'+
  '[somefield],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],'+
  '[somefield],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],'+
  '[somefield],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],'+
  '[somefield],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],;

lQuery2 :=
  '[somefield],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],'+
  '[somefield],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],'+
  '[somefield],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],'+
  '[somefield],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],[fieldname],'+

  'FROM ['+aDatabaseName+'].[DBO].['+aCompanyName+'$Sales Invoice Header]'+
  'WHERE ([fieldname] <> '''') AND ([fieldname] = ''1753-01-01 00:00:00.000'')';

ADORecordsetSalesInvoiceHeader := SQLADOServer.Execute(lQuery1+lQuery2);  <---------------------------------------------------


Best regards / Venlig hilsen
Johannes Sebastian
MB7-840,MB7-841
Sign In or Register to comment.