_ConnectionPtr m_Connection;
_RecordsetPtr m_Recordset;
CString sCarNum="";
_bstr_t sDataType="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Manage.mdb;"; //初始化OLE环境
AfxOleInit(); //连接数据库
m_Connection.CreateInstance(_uuidof(Connection));
m_Connection->Open(sDataType,"","",NULL);
//连接数据集
m_Recordset.CreateInstance(_uuidof(Recordset));
m_Recordset->Open(_variant_t("车辆信息"),m_Connection.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdTable); //数据操作
sCarNum=(char*)(_bstr_t)m_Recordset->Fields->GetItem(_variant_t("车牌类型"))->Value;
AfxMessageBox(sCarNum); if (!m_Recordset->Supports(adAddNew)) return;

m_Recordset->AddNew(); m_Recordset->Fields->GetItem(_variant_t("记录日期"))->Value=(_bstr_t)"2006-03-12";
m_Recordset->Fields->GetItem(_variant_t("车牌号码"))->Value="京HJ8888";
m_Recordset->Fields->GetItem(_variant_t("车牌颜色"))->Value="黄色";
m_Recordset->Fields->GetItem(_variant_t("车牌类型"))->Value="大功率汽车";
m_Recordset->Update();
m_Recordset->Close();
程序运行后,出现"Unhandled exception in DataBase1.exe (KERNEL32.DLL):0xE06D7363:Microsoft C++ Exception."错误~~~调试发现问题出在m_Recordset->AddNew();这句上,请问是什么原因引起的这个问题?该怎么解决~?

解决方案 »

  1.   

    try catch _com_error
    void dump_com_error(_com_error &e)
    { CString ErrorStr;

    _bstr_t bstrSource(e.Source());
    _bstr_t bstrDescription(e.Description());
    ErrorStr.Format( "Error\n\tCode = %08lx\n\tCode meaning = %s\n\tSource = %s\n\tDescription = %s\n",
    e.Error(), e.ErrorMessage(), (LPCSTR)bstrSource, (LPCSTR)bstrDescription);
    m_strErrorDescription = (LPCSTR)bstrDescription ;
    m_strLastError = _T("Connection String = " + GetConnectionString() + '\n' + ErrorStr);
    m_dwLastError = e.Error(); }
      

  2.   

    记起来了,以前有碰到类似的问题, 升级一下数据驱动,MDAC_TYPE。
      

  3.   

    baidu 搜索 MDAC_TYPE最新好像是2。8