Retrieving SQL Records between dates with Delphi ADO
Posted on 2014-08-20
I have assembled from researching the Web what I thought was the best solution for retrieving records from a SQL 2008/R2 database using two Delphi DateTime pickers. The code is as follows;
InvoiceQuery.SQL.Text :='SELECT SUM(FullPrice)FROM [TransactionEntry] WHERE TransactionTime BETWEEN DatePicker1.Date AND DatePicker2.Date';
InvoiceQuery.Parameters.ParamByName('FromDate').Value := DateOf(DatePicker1.Date);
InvoiceQuery.Parameters.ParamByName('ToDate').Value := DateOf(DatePicker2.Date);
Running the code I get an EOLexeception message; "Parameter Object is improperly defined. Inconsistent or incomplete information was provided."
I've tried all of the 'Name - Value' combinations I can think of in the Parameters editor for the Delphi ADOQuery component which the same result, any help will be greatly appreciated