Re: Multiple Steps OLE DB generated errors.



fiaola formulated the question :
I'm getting this error when on this QUERY. Data is an AS/400 Database and D7 using ADO OLE Connection.

ERROR: Multiple steps OLE DB generated errors.

Here is the query. It was working fine before, but now i'm getting this error.

SQL.Add('Select a.U0GLN, a.U0BDT, a.U0CRC, a.U0AM0, b.UGGLN, b.UGDES ');
SQL.Add('From "MYLIB"."UBCRJT" a, ');
SQL.Add('"MYLIB"."UBGLMST" b');
SQL.Add('WHERE a.U0GLN = b.UGGLN');
SQL.Add('AND a.U0BDT >= :pDateFrom '); {AND :pDateTo ');}
SQL.Add('AND a.U0BDT <= :pDateTo ');

Parameters.ParamByName('pDateFrom').Value := FormatDatetime('YYYYMMDD', dtFrom.Date);
Parameters.ParamByName('pDateTo').Value := FormatDateTime('YYYYMMDD', dtTo.Date);
Open;

Any suggestion would be appreciated.

Thanks

First you do not need to convert the date parameters to string just assign them as dates and the rest are taken care by the library.
Second if you do convert them make sure that you have the correct format for example in MS SQL server the correct format would be 'YYYY-MMM-DD' with out the dushes it raises an error.
Third when you do convert them to a string then the values must enclosed in single or double quotes so use the command
QuotedStr(FormatDateTime('YYYYMMDD', dtTo.Date));
for single quotes or add '"'+ FormatDateTime.......+'"' for double quotes.

After all of the above are taken care then try to collect the error messages from the errors collection of the ADOConnection.

Regards
Yannis.


.