_CommandPtr   m_pCommand;   
_ConnectionPtr m_pConnection; // 初始化COM,创建ADO连接等操作
    CoInitialize(NULL);
    m_pConnection.CreateInstance(__uuidof(Connection));
try
{
m_pConnection->Open( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=cvd.mdb", "", "", adModeUnknown );
}
catch (_com_error &e)
{
cout<<e.ErrorMessage()<<endl;
}


// 使用ADO创建数据库记录集
m_pRecordset.CreateInstance(__uuidof(Recordset));
try
{
m_pRecordset->Open("SELECT * FROM  cvd",           // 查询cvdfirst表中所有字段
m_pConnection.GetInterfacePtr(),                // 获取库接库的IDispatch指针
adOpenStatic,
adLockOptimistic,
adCmdText);
}
catch(_com_error &e)
{
cout<<e.ErrorMessage()<<endl;
}  m_pCommand = m_pConnection->Execute("alter   table   cvd   drop   column   JOB", NULL, 0);

解决方案 »

  1.   

    Unhandled exception ..... : 0xE06D7363:Microsoft C++ Exception
      

  2.   


    用连接对象的执行方法时,不需要再用记录集对象打开表。1、先连接数据库,保证连接成功;
    2、直接执行删除列的SQL语句:CString strSQL = "alter   table   cvd   drop   column   JOB";try 

      m_pConnection->Execute((_bstr_t)strSQL,NULL,adCmdText);

    catch(_com_error &e) 

      cout < <e.Description() < <endl; 
    }   
      

  3.   

    SQL 分为两部分:DDL 和 DCL
      

  4.   

    你把你的sql直接放到access中做个查询
      

  5.   

    调用下面语句之前,要先关掉你前面打开的cvd表m_pRecordset->Close();m_pCommand = m_pConnection->Execute("alter   table   cvd   drop   column   JOB", NULL, 0);