 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Dan Guest
|
Posted: Tue Feb 03, 2004 7:48 pm Post subject: Re: Data Type Mismatch Access TADOQuery DateTime |
|
|
On Mon, 2 Feb 2004 19:35:14 -0000, "G Smith" <g.smith2 (AT) ntlworld (DOT) com>
wrote:
| Quote: | Hi,
Im quite new to delphi and am experiencing the following problem.
Im using a TADOQuery to retrieve a date from a Access database and then wish
to use it again in another sql query, but i am getting data mismatch
exceptions.
q4.sql.text := 'SELECT (SELECT max(DateTimeMod) from LOTracking where
(LOTracking.LOID) = '+inttostr(q.fieldvalues['ID'])+') as LVDate from
LOTracking where (LOTracking.LOID) = '+inttostr(q.fieldvalues['ID']);
q4.open;
q5.sql.text := 'SELECT LOTracking.PersonID from LOTracking where
(LOTracking.LOID = '+inttostr(q.fieldvalues['ID']) +') and
(LOTracking.DateTimeMod = '''+datetimetostr(q4.fieldvalues['LVDate'])+''')';
|
I'm not a user of ADO, so this may be way off.
One often used method is to have a parameter for the datetime value,
rather than trying to explicitly format it. So you would have:
(LOTracking.DateTimeMod = :dtime)
q5.parambyname('dtime').AsDateTime :=
q4.FieldByName('LVDate').AsDateTime;
| Quote: | q5.open;
This method usually solves mismatch problems for me. |
HTH,
Dan
| Quote: | The DateTimeMod field is General Date Time format. When using the delphi
debugger to view the LVDate it is identical to that in the database and
should work.
Any help would be much appreciated,
Thanks
|
|
|
| Back to top |
|
 |
G Smith Guest
|
Posted: Wed Feb 04, 2004 9:12 pm Post subject: Re: Data Type Mismatch Access TADOQuery DateTime |
|
|
Thanks a lot seems to work perfectly !
"Dan" <Doculus at CMDCsystems dot com> wrote
| Quote: | On Mon, 2 Feb 2004 19:35:14 -0000, "G Smith"
wrote:
Hi,
Im quite new to delphi and am experiencing the following problem.
Im using a TADOQuery to retrieve a date from a Access database and then
wish
to use it again in another sql query, but i am getting data mismatch
exceptions.
q4.sql.text := 'SELECT (SELECT max(DateTimeMod) from LOTracking where
(LOTracking.LOID) = '+inttostr(q.fieldvalues['ID'])+') as LVDate from
LOTracking where (LOTracking.LOID) = '+inttostr(q.fieldvalues['ID']);
q4.open;
q5.sql.text := 'SELECT LOTracking.PersonID from LOTracking where
(LOTracking.LOID = '+inttostr(q.fieldvalues['ID']) +') and
(LOTracking.DateTimeMod =
'''+datetimetostr(q4.fieldvalues['LVDate'])+''')';
I'm not a user of ADO, so this may be way off.
One often used method is to have a parameter for the datetime value,
rather than trying to explicitly format it. So you would have:
(LOTracking.DateTimeMod = :dtime)
q5.parambyname('dtime').AsDateTime :=
q4.FieldByName('LVDate').AsDateTime;
q5.open;
This method usually solves mismatch problems for me.
HTH,
Dan
The DateTimeMod field is General Date Time format. When using the delphi
debugger to view the LVDate it is identical to that in the database and
should work.
Any help would be much appreciated,
Thanks
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|