我用的sql7.0桌面版.
CRecordset我用的是snapshot .
插入数据时提示记录集是只读的.在open时我指定CRecordset::appendOnly和CRecordset::none都不管用.
如何解决.

解决方案 »

  1.   

    if(FALSE == tmpCZYRecord.Open(AFX_DB_USE_DEFAULT_TYPE))
    {
    TRACE("in add user failed open record\n");
    AfxMessageBox("数据库操作失败");
    return;
    }
    if(0 != tmpCZYRecord.GetRecordCount())
    {
    AfxMessageBox("此操作员ID已经使用了,请另换一个.");
    tmpCZYRecord.Close();
    return;
    }
    tmpCZYRecord.AddNew();
    tmpCZYRecord.m_CzyId = tmpId;
    tmpCZYRecord.m_CzyLx = tmpLb;
    tmpCZYRecord.m_CzyName = tmpName;
    tmpCZYRecord.m_CzyPass = CreateNullPass();
    tmpCZYRecord.m_CzyQyFlag = tmpZt;
    if(FALSE == tmpCZYRecord.Update())
    {
    tmpCZYRecord.Close();
    AfxMessageBox("添加操作员失败");
    return;
    }
    else
    {
    tmpCZYRecord.Close();
    AfxMessageBox("添加操作员成功");
    return;
    }
    }
    catch(CDBException *pe)
    {
    TRACE("IN ADD USER FAILED EXCEPTION\n");
    AfxMessageBox("添加操作员失败");
    tmpCZYRecord.Close();
    pe->ReportError();
    pe->Delete();
    return;
    }
    }在Addnew()时出现了异常
      

  2.   

    1.AFX_DB_USE_DEFAULT_TYPE是系统默认的.你试试snapshot,或者别的.
    2.是不是数据库本身就不支持修改?