如果使用“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!!请高手帮助!不胜感激!!
_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!!请高手帮助!不胜感激!!
SELECT * FROM tablename 直接 给open
try
{
DBItem->Open(_T("select * from station"),
ConnDB.GetInterfacePtr(),
adOpenDynamic,
adLockOptimistic,
adCmdText);
}
catch(_com_error e)
{
AfxMessageBox(e.ErrorMessage());
}
还是不行!