Board index » cppbuilder » Why have I got wrong record from this table?

Why have I got wrong record from this table?


2006-11-02 03:53:32 PM
cppbuilder31
I used ADO to access a Ms Access database.I put a TAdoConnection, a
TADOTable, a TDataSource and a TDBGrid into the Form,the I have actived the
dataset,but some datas displayed in the grid is dislike that in the Ms
Access.especially the field whose type is DateTime,for example:In ms access
a record's datetime field is 2006-11-20 12:12:31,but in my test application,
this field has changed to 2006-11-20 12:12:31,so I tested this database in
vb by ocx,the result is correct.Is the reason in my access table???
 
 

Re:Why have I got wrong record from this table?

"ht" < XXXX@XXXXX.COM >写入邮件 news: XXXX@XXXXX.COM ...
I used ADO to access a Ms Access database.I put a TAdoConnection, a
TADOTable, a TDataSource and a TDBGrid into the Form,the I have actived the
dataset,but some datas displayed in the grid is dislike that in the Ms
Access.especially the field whose type is DateTime,for example:In ms access
a record's datetime field is 2006-11-20 12:12:31,but in my test application,
this field has changed to 2006-11-20 12:12:30,so I tested this database in
vb by ocx,the result is correct.Is the reason in my access table???
 

Re:Why have I got wrong record from this table?

Quote
2006-11-20 12:12:31
2006-11-20 12:12:31
I see no difference in these two date values. What did you mean to type?
To control the display format of a field you can find the field in the
dataset and then modify the 'DisplayFormat' property to your liking.
For instance to specify that the display format should be "2006/11/20":
TDateTimeField* field = dynamic_cast <TDateTimeField*>
(DataSet1->Fields->FieldByName("SomeDateField"));
if (field)
field->DisplayFormat = "yyyy/mm/dd";
HTH,
- Clayton
 

{smallsort}

Re:Why have I got wrong record from this table?

When I first read your second message it appeared to me that you
accidentally replied to your own message. However, I just read it again and
saw that you changed a 31 to a 30. For future reference, when you are
correcting something you wrote please make it obvious. For instance:
I mistyped the bad date. It should have been "2006-11-20 12:12:30".
This would make it apparent why the second post exists.
However, to answer your question. It could be a floating point rounding
error though I've never seen that happen to a TDateTime before without some
sort of arithmetic involved.
I'll keep my eyes open to try to find out what the issue is. Hopefully
someone else that knows what's going on will respond.
- Clayton
 

Re:Why have I got wrong record from this table?

"Clayton Arends" < XXXX@XXXXX.COM >写入消息新闻:454a2986$ XXXX@XXXXX.COM ...
Quote
When I first read your second message it appeared to me that you
accidentally replied to your own message. However, I just read it again
and saw that you changed a 31 to a 30. For future reference, when you are
correcting something you wrote please make it obvious. For instance:

I mistyped the bad date. It should have been "2006-11-20 12:12:30".

This would make it apparent why the second post exists.

However, to answer your question. It could be a floating point rounding
error though I've never seen that happen to a TDateTime before without
some sort of arithmetic involved.

I'll keep my eyes open to try to find out what the issue is. Hopefully
someone else that knows what's going on will respond.

- Clayton

Thank you,Clayton!I have seen my program again,I thought maybe you are
right.Because the DateTime was reprented as a float value in the access,and
In my application I put data into the table every 200ms, perhaps the
difference was the different convertion method between Borland and
Microsoft.so you are right:It could be a floating point rounding .
 

Re:Why have I got wrong record from this table?

I experienced something similar to this one, when I was migrating
DateTime values from an MS Access db to MySQL using TADOQuery. My code
looked something like this:
while (!adoAccess->Eof)
{
adoMySQL->Append();
adoMySQLDT->Value = adoAccessDT->Value;
adoMySQL->Post();
adoAccess->Next();
}
When I inspected the migrated records on MySQL, I found out that most
of the records were off by a second. But if I do this:
adoMySQLDT->Value = StrToDateTime(DateTimeToStr(adoAccessDT->Value));
The resulting records are correct.
Another baffling thing is prior to this one, I had no problem migrating
DateTime values from Interbase/Firebird (using DBX) to MySQL (using
ADO).
- Erol