BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Why have I got wrong record from this table?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (ADO)
View previous topic :: View next topic  
Author Message
ht
Guest





PostPosted: Thu Nov 02, 2006 9:10 am    Post subject: Why have I got wrong record from this table? Reply with quote



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???
Back to top
ht
Guest





PostPosted: Thu Nov 02, 2006 8:27 pm    Post subject: Why have I got wrong record from this table? Reply with quote



"ht" <ht_ftp (AT) km169 (DOT) net> 写入邮件 news:4549a412 (AT) newsgroups (DOT) borland.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???
Back to top
Clayton Arends
Guest





PostPosted: Thu Nov 02, 2006 11:15 pm    Post subject: Re: Why have I got wrong record from this table? Reply with quote



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
Back to top
Clayton Arends
Guest





PostPosted: Thu Nov 02, 2006 11:23 pm    Post subject: Re: Why have I got wrong record from this table? Reply with 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
Back to top
ht
Guest





PostPosted: Fri Nov 03, 2006 9:10 am    Post subject: Re: Why have I got wrong record from this table? Reply with quote

"Clayton Arends" <nospam_claytonarends (AT) hotmail (DOT) com> 写入消息新闻:454a2986$1 (AT) newsgroups (DOT) borland.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 .
Back to top
Erol Fornoles
Guest





PostPosted: Thu Nov 23, 2006 9:10 am    Post subject: Re: Why have I got wrong record from this table? Reply with quote

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
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder Databases (ADO) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.