CTime CurrentTime = CTime::GetCurrentTime();
 CString   strText   =   CurrentTime.Format("%y-%m-%d %H:%M:%S");CString str;
str.Format("Insert into t_Tag(TagID,Time,x,y,z) values('%s','%s',%f,%f,%f)",m_TagID,strText.GetBuffer(),x,y,z);每次运行上面那句的时候 就会中断  (msvcr80d.dll) 处未处理的异常: 0xC0000005: 读取位置 0xcdcdcdcd 时发生访问冲突
,好像问题主要在Time字段,因为去掉这个字段程序就没问题的

解决方案 »

  1.   

    我不知道 m_TagID是什么类型的,就胡乱改了一个
    测试过能正常运行
    CTime CurrentTime = CTime::GetCurrentTime(); 
    CString   strText   =   CurrentTime.Format("%y-%m-%d %H:%M:%S"); 
    CString m_TagID;
    m_TagID= "king";
    double x,y,z;
    CString str; 
    str.Format(_T("Insert into t_Tag(TagID,Time,x,y,z) values('%s','%s',%f,%f,%f)"),m_TagID,strText.GetBuffer(),x,y,z); 
      

  2.   

    也不知道楼主用的什么DBMS?
    先把那个叫【Time】的字段改个名字,尽量不要用关键字。另外,就是用 catch 捕获错误看看了。
      

  3.   


    如果这样的话  就可以顺利通过这条语句
    CString str; 
    str.Format("Insert into t_Tag(TagID,x,y,z) values('%s',%f,%f,%f)",m_TagID,x,y,z);