0

I send with Jquery and Ajax Parameters from the Webpage to my Delphi Webserver. Those Parameters will be used in the select, but as soon as i get to TADOQ.Open; i get a exception which contains the message bellow the code section.

I'm new to Delphi, so it's not easy for me to understand how to work with UnicodeString, AnsiString and String. Also i don't understand why it says double, when i don't use it anywhere.

Is there a simple way to fix the Problem? (Small Code and easy to unterstand)

EDIT: Added Process before calling SearchChosen();

KoyoWebSqlReader:=CKoyoWebSqlReader.Create;
KoyoWebSqlReader.OpenConnection;

Response.ContentType:='application/json';
Txt:=KoyoWebSqlReader.SearchChosen(
  StrToInt(SplitString(Request.ContentFields[0], '=')[1]),
  StrToDateTime(SplitString(Request.ContentFields[1], '=')[1])
).toJsonString;
Response.Content:=Txt;

KoyoWebSqlReader.CloseConnection;

// -----

function CKoyoWebSqlReader.SearchChosen(TicketNumber:Integer; Start:TDateTime):CKoyoMeasurement;
var Search:TADOQuery;
var Measurement:CKoyoMeasurement;
begin
    Measurement:=CKoyoMeasurement.Create;

    Search:=TADOQuery.Create(nil);
    Search.Connection:=Connection;
    Search.SQL.Clear;
    Search.SQL.Text:=
    'SELECT * FROM Measurements WHERE TicketNumber = :TicketNumber AND Start = :Start;';
    Search.Parameters.ParamByName('TicketNumber').Value:=TicketNumber;
    Search.Parameters.ParamByName('Start').Value:=Start;

    try
    Search.Open;
    // Fill Measurement
    except on EX:Exception do
    begin
    // Log Exception
    end;
end;
Search.Close;
Result:=Measurement;
end;

Variant of Type (UnicodeString) could not be converted into (Double)

René
  • 1
  • 4
  • Why is your date a string and not TDatetime? – whosrdaddy Jul 18 '18 at 08:52
  • Your q is self-contradictory. You say " but as soon as i get to TADOQ.Open;" but you call `Search.Open`. Which is it? Please always post your **actual** code cut&pasted from your project. Btw, using the **T** prefix for a class instance (`TADOQ`) but **not** using it for your own class type (`MyOwnClass`) is asking for trouble. – MartynA Jul 18 '18 at 08:56
  • Looks like your Number string variable does not contain a valid number (maybe it's an empty string ?). – Marc Guillot Jul 18 '18 at 09:06
  • Oh sorry, i edited it to the specific code (no general names), also changed the types to Integer and TDatetime | Marc - The String (now int and datetime) is 2666905 (int) | 06.06.2018 21:52:00 (datetime). I logged it exactly for the purpose of seeing if it is an empty string/value – René Jul 18 '18 at 09:17
  • You changed the question, you got the error because internally delphi will want to convert your date string into a TDateTime (which is an alias type for double)... – whosrdaddy Jul 18 '18 at 09:21

0 Answers0