Recent

Author Topic: MS Access and ODBCConnection: Error when inserting a date!  (Read 1104 times)

Jvan

  • Full Member
  • ***
  • Posts: 181
MS Access and ODBCConnection: Error when inserting a date!
« on: June 01, 2021, 09:33:29 pm »
I have a MS Access database with a date column.

Code: Pascal  [Select][+][-]
  1. SQLQuery2.ParamByName('FECHA').AsDate := EncodeDate(arr1[2].ToInteger, arr1[1].ToInteger, arr1[0].ToInteger);
  2. ...
  3.  
  4. SQLQuery2.ExecSQL();
  5. SQLTransaction1.Commit();    
  6.  

I got an error message, but when I change the date column to text, it works ok, but I need it as a date.

wp

  • Hero Member
  • *****
  • Posts: 8567
Re: MS Access and ODBCConnection: Error when inserting a date!
« Reply #1 on: June 01, 2021, 10:57:10 pm »
The computer is right: April has only 30 days... (https://en.wikipedia.org/wiki/Knuckle_mnemonic).

Nevertheless, I checked if dates work as parameters in Access queries. Yes, they do, no need for the surrounding '#', the '/' date separator and the month-day-year order - see attached demo.


Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

Jvan

  • Full Member
  • ***
  • Posts: 181
Re: MS Access and ODBCConnection: Error when inserting a date!
« Reply #2 on: June 02, 2021, 12:34:26 am »
Thanks.

 

TinyPortal © 2005-2018