如果使用“SQL SERVER”验证方式,程序没有任何问题。如果改成标题所述的方式时, 在:
_RecordsetPtr DBItem = NULL; CString strSQL;
strSQL.Format(_T("SELECT * FROM tablename");

DBItem.CreateInstance(__uuidof(Recordset)); try
{
DBItem->Open(strSQL.AllocSysString(), 
                                ConnDB.GetInterfacePtr(),  //ConnDB->Open 正常
                                adOpenDynamic, 
                                adLockOptimistic,
                                adCmdText);
}
catch(_com_error e)
{
AfxMessageBox(e.ErrorMessage());
}
时就会出现错误:IDispatch error #3081!!请高手帮助!不胜感激!!

解决方案 »

  1.   

    ConnDB 检查连接字符串
    SELECT * FROM tablename 直接 给open
      

  2.   

    试了一下,改成了如下样子:
    try
    {
    DBItem->Open(_T("select * from station"), 
                                   ConnDB.GetInterfacePtr(), 
                                   adOpenDynamic, 
                                   adLockOptimistic,
                                    adCmdText);
    }
    catch(_com_error e)
    {
    AfxMessageBox(e.ErrorMessage());
    }
    还是不行!