|
-
February 14th, 2005, 11:17 AM
#1
ADO: Getting Milliseconds
Hi ...
I am trying to get Milliseconds from a SQL Database using ADO. The code below will return 0 for the wMilliseconds.
Any comments / solutions.
Thanks,
Chris
Code:
// Some code is removed for clarity
_variant_t vTemp;
COleDateTime codtUpdateDateTime;
// Define ADO connection pointers
_ConnectionPtr pConnection = NULL;
_RecordsetPtr pRecordset = NULL;
try
{
// When we open the application we will open the ADO connection
pConnection.CreateInstance(__uuidof(Connection));
// Open the ado connection
pConnection->Open(bstrConnect,"","",adConnectUnspecified);
// Select all the records
csSQL = "SELECT * FROM dbo.MacgowanTest00";
// Create an instance of the database
pRecordset.CreateInstance(__uuidof(Recordset));
// This is required to support the Sort Property
pRecordset->CursorLocation = adUseClient;
// Open the recordset
pRecordset->Open(LPCTSTR(csSQL),
pConnection.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
while (pRecordset->GetadoEOF() == VARIANT_FALSE)
{
vTemp = pRecordset->Fields->GetItem(L"UpdateDateTime")->Value;
// Try to get the millisonds here
SYSTEMTIME sTime;
codtUpdateDateTime = vTemp.date;
codtUpdateDateTime.GetAsSystemTime(sTime);
int ms=sTime.wMilliseconds;
}
}
catch(...)
{
// handle error
}
-
February 14th, 2005, 01:01 PM
#2
Re: ADO: Getting Milliseconds
Well..., why are you sure the "Milliseconds" must be non-zero?
-
February 14th, 2005, 04:24 PM
#3
Re: ADO: Getting Milliseconds
Chris,
This could be a timer resolution problem. I have the same type of code in my computer and it does the same thing. I remember reading somewhere that the timer resolution in XP is about 15ms, so a search taking less than 15ms will show 0ms. If anyone can verify this correct or incorrect please step on my toes, I'd rather have that than incorrect information. Try putting a Sleep(30) in your code before "codtUpdateDateTime.GetAsSystemTime(sTime);" and then ck your time.
Jim
ATP BE400 CE500 (C550B-SPW) CE560XL MU300 CFI CFII
"The speed of non working code is irrelevant"... Of course that is just my opinion, I could be wrong.
"Nothing in the world can take the place of persistence. Talent will not; nothing is more common than unsuccessful men with talent. Genius will not; unrewarded genius is almost a proverb. Education will not; the world is full of educated derelicts. Persistence and determination are omnipotent. The slogan 'press on' has solved and always will solve the problems of the human race."...Calvin Coolidge 30th President of the USA.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|