我以前获得系统日期时间的方法是:
time_t ltime;
time(&ltime);
现在想要转化成ACCESS数据库的时间格式,请大哥帮忙解决一下,谢谢

解决方案 »

  1.   

    CTime time;
        time = CTime::GetCurrentTime();
        CString str = time.Format("#%Y-%m-%d %H:%M:%S#");
      

  2.   

    CTime time;
     time = CTime::GetCurrentTime();
     CString str = time.Format("#%Y-%m-%d %H:%M:%S#");
    m_pConnection->Execute("INSERT INTO yyk(时间,标题,备注) VALUES ('"+(_bstr_t)str+"','aldjoial','41')",&RecordsAffected,adCmdText);
    这是数据库里添加记录的代码,编译没问题,运行出错误,检查后问题就是出在'"+(_bstr_t)str+"'上,请问该怎么办?放心,我会多加分的
      

  3.   

    呵呵,没事了,我把CString str = time.Format("#%Y-%m-%d %H:%M:%S#");改为
    CString str = time.Format("%Y-%m-%d %H:%M:%S");就可以了,谢谢了