Page 1 of 1
problem with datetime field
Posted: Mon 20 Nov 2006 14:34
by Edison Garcia
I am a new user of MyDac. I tryed to use the following line (MySQL 5 / Delphi 7):
......
MyTableX.fieldbyname('AdateTimeField').asdatetime := Now;
and I get an error of imcompatible fields.
so I tryed:
......
MyQueryX.parambyname('AdateTimeField').asdatetime := Now;
and I get the same.
How can I move a DateTime value like Now to a MySQL field Datetime?
Using a trigger, the same field acceptssomething like Set ADateTimeFiled to curret_timestamp, but the field is defined as Datetime.
Thank you
Edison
Posted: Mon 20 Nov 2006 15:37
by Antaeus
If c_datetime is a field of DATETIME type, the following code should work:
Code: Select all
MyQuery.Open;
MyQuery.Insert;
MyQuery.FieldByName('c_datetime').AsDateTime := Now;
MyQuery.Post;
Send us (evgeniyD*crlab*com) a complete small sample to demonstrate the problem if the tip above does not help. Also do not forget to include script to create and fill table(s).
Also supply us with the following information:
- Exact error message you get
- Exact version of Delphi, C++ Builder or Kylix you use
- Exact version of MyDAC. You can see it in About sheet of TMyConnection Editor
- Exact version of MySQL server and MySQL client. You can see it in Info sheet of TMyConnection Editor
DateTime problem
Posted: Tue 21 Nov 2006 13:00
by Edison Garcia
Thank you for your answer, but, as you can see in my original message, the line you sugest is exactly the line that I try to use, and more, I triyed to use also as a parambyname....as datetime := Now and get the same error.
Now I am not with the machine where I have MyDac installed, so I can not send all you ask ( I will do it at night), but I can give part of the information:
- Exact error message you get ( I wiil send later)
- Exact version of Delphi, C++ Builder or Kylix you use
Delphi 7 professional with updates installed
- Exact version of MyDAC. You can see it in About sheet of TMyConnection Editor
Probably the last one, since I had made the purchase and download less than 15 days ago;
- Exact version of MySQL server and MySQL client. You can see it in Info sheet of TMyConnection Editor
Version 5.024
I did not use any script to create the table. I use EMS mannager and create the table manually, but if you extract the metadata of the table you can see that the field is defined as DateTime. ( I wikk send it at night also)
Thank you
Edison
Posted: Wed 22 Nov 2006 02:21
by Edison Garcia
I could not reproduce the error anymore! It works pefectly!
Probably I was some hours after my "sleeping point"!
Sorry and thank you
Edison Garcia