Bug #5395 MyODBC ver.3.51 bug: #1026
Submitted: 3 Sep 2004 18:03 Modified: 4 Jun 2005 6:45
Reporter: Andres Sanchez Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:3.51 OS:Microsoft Windows (Windows XP)
Assigned to: CPU Architecture:Any

[3 Sep 2004 18:03] Andres Sanchez
Description:
Somebody knows what happening with bug: #1026 about the problem with the datetime query param executed from a delphi 6 application.? 
Ive got this problem and I was trying with another connector from older version but I was found another problem that my application becomes very slow. 

Thanks.

How to repeat:

Query = TQuery component 

Me ocurrio en una rutina de este tipo:

Query.Add( 'INSERT INTO FECHAS(NOINS, LASTREAD.DATETIME) VALUES (:ni, :ul)');
      with Query do begin
         params[0].asstring := 'pepito'
         params[1].asdatetime := now - 1;
         execSQL;
      end;
[3 Sep 2004 18:43] Andres Sanchez
Im sorry, I forgot that Before comment was related to MySQL database and MyODBC connector ver. 3.51 over win Xp
[8 Dec 2004 15:58] Mathieu Tremblay
You just have to transform the Date into String before posting the query
like this 

var
  FormatSettings: TFormatSettings;

GetLocaleFormatSettings(LOCALE_USER_DEFAULT, FormatSettings);
FormatSettings.DateSeparator := '-';
FormatSettings.longDateFormat:='d mmmm yyyy';

Query.Add( 'INSERT INTO FECHAS(NOINS, LASTREAD.DATETIME) 
                VALUES (:ni, :ul)');
      with Query do begin
         params[0].AsString := 'pepito'
         params[1].AsString := DateTimeToStr(Now - 1, FormatSettings);
         execSQL;
      end;
[3 Jun 2005 16:33] KAZANCI ibrahim
i'm using delphi 5, mysql 4.1.10a
i have same similiar error. i'm trying to port my delphi+mssql application to delphi+mysql. i can't send any datetime parameter to any TQuery component in delphi. 

i'm using delphi 5 and suggested Tformatstring is not defined in this version. i cant solve problem.
i used it with other mysql 4 versions. there is no difference.

this is an example:

        qryMesaj.Close;
        qryMesaj.SQL.Clear;
        qryMesaj.SQL.Add('SELECT * FROM Messages');
        qryMesaj.SQL.Add('WHERE Date <=:QDate');
        qryMesaj.ParamByName('QDate').AsDateTime := Date; //--> error here
        qryMesaj.Open;

same query working good with mssql.

i'm reading about myodbc & datetime parameter problem on forums a lot but there is not a real solution.