主题:利用ADO操作数据库出现的时间问题
从ACCESS中读取时间出现了问题,都是1970-1-1 8:00:00
代码如下:
_variant_t var;
if(!m_pRecordset->BOF)
{
m_pRecordset->MoveFirst();
while(!m_pRecordset->adoEOF)
{
var=m_pRecordset->GetCollect("时间");
if(var.vt!=VT_NULL)
times=var.date;//(LPCSTR)_bstr_t(var);
m_pRecordset->MoveNext();
}
}
COleVariant vtime(times);
COleDateTime time=vtime;
SYSTEMTIME systime;
VariantTimeToSystemTime(time,&systime);
CTime tm(systime);
m_date.Format("%d:%d:%d:%d:%d:%d",tm.GetYear(),tm.GetMonth(),tm.GetDay(),tm.GetHour(),tm.GetMinute(),tm.GetSecond());
不知道有人碰到这样的情况没有,帮帮我,问题出现什么地方?
如果我不进行类型转换是正确的,那位大侠可以帮我解决这个问题吗?
代码如下:
_variant_t var;
if(!m_pRecordset->BOF)
{
m_pRecordset->MoveFirst();
while(!m_pRecordset->adoEOF)
{
var=m_pRecordset->GetCollect("时间");
if(var.vt!=VT_NULL)
times=var.date;//(LPCSTR)_bstr_t(var);
m_pRecordset->MoveNext();
}
}
COleVariant vtime(times);
COleDateTime time=vtime;
SYSTEMTIME systime;
VariantTimeToSystemTime(time,&systime);
CTime tm(systime);
m_date.Format("%d:%d:%d:%d:%d:%d",tm.GetYear(),tm.GetMonth(),tm.GetDay(),tm.GetHour(),tm.GetMinute(),tm.GetSecond());
不知道有人碰到这样的情况没有,帮帮我,问题出现什么地方?
如果我不进行类型转换是正确的,那位大侠可以帮我解决这个问题吗?