这种问题在运行时,有时出现,有时不出现,完全不明白到底什么原因。
希望高手指点迷津。

解决方案 »

  1.   

    是打开记录集时出错还是读取某一条记录时出错,如果是读取记录则要检查一下你读取的字段值是否是VT_NULL,另外对于数据库的操作最好是加一个try catch,这样可以捕获到错误原因,如: try
    {
    ;//操作数据库的代码
    }
    catch(_com_error &e)
    {
    AfxMessageBox(e.Description());//显示错误原因
    }
      

  2.   

    参看:http://support.microsoft.com/kb/130719/en-us这是微软官方文件,内有解决方案。
      

  3.   

    void fun()
    {CUserBuildSet set;
    strSql.Format("select* from 建筑表 );
    set.Open(AFX_DB_USE_DEFAULT_TYPE,"select* from 建筑表");
    while(!set.IsEOF())
    {
     if("电厂"==set.m_BuildName)
       {
    set.Edit();
    set.m_StoreNum=m_nStoreElecNum;
    set.Update();
            break
       }
    set.Close();
    }
    以上函数,单击一个特点按钮执行一次,第一次单击该按钮执行该函数时一般不错,当第二或第三次单击按钮执行该该函数时,在执行set.Open()时一定报错“常见错误 不能创建文件缓冲区”.
      

  4.   

    我试着改成如下代码:在Set.Edit()执行时报错“记录集是只读”。
    void fun() 
    {CDatabase base;
    base.OpenEx("DSN=UserBuild");
    CUserBuildSet set(&base); 
    set.Open(AFX_DB_USE_DEFAULT_TYPE,"select* from 建筑表"); 
    while(!set.IsEOF()) 
     { 
       if("电厂"==set.m_BuildName) 
       { 
        set.Edit(); 
        set.m_StoreNum=m_nStoreElecNum; 
        set.Update(); 
            break 
        } 
     }
     set.Close();
     base.Close(); 

      

  5.   

    回二楼:
    To avoid the error, create a file named CTT0.TMP, and place it in the directory that the cursor library uses to generate its temporary files.
    CTT0.TMP文件应该放在哪个目录下?
    我把它分别放在debug目录下和工程目录下都没有效果
      

  6.   


    To use an updatable dynaset, you must have a unique index on one or more fields in the table. If there is no such index, the recordset will be read only. Also, CRecordset::CanAppend() and CRecordset::CanUpdate() will return FALSE. 
      

  7.   

    //用这个试试
    CDatabase db; 
    db.Open(NULL, false, false, "ODBC;DSN=myDSN;UID=;PWD="); 
    CMySet set(&base); 
    set.Open(AFX_DB_USE_DEFAULT_TYPE,"select* from 表名");
      

  8.   

    //用这个试试
    CDatabase db;  
    db.Open(NULL, false, false, "ODBC;DSN=myDSN;UID=;PWD=");  
    CMySet set(&base);  
    set.Open(AFX_DB_USE_DEFAULT_TYPE,"select* from 表名");