The following code fragment works when compiled in VS2003 on both Windows XP Pro (32-bit) and WindowsXP Pro x64.
However, when compiled under VS2005, the call to 'pMyRecordsetPtr->RecordCount' fails on both 32bit and 64bit WindowsXP.
I have tried #import'ing msado20.tlb and msado27.tlb.
Has anybody had any similar experience?
HRESULT hr = ::CoInitialize(NULL);
if (FAILED(hr))
{
return false;
}
_ConnectionPtr pConnection;
hr = pConnection.CreateInstance(__uuidof(Connection));
if (FAILED(hr))
{
return false;
}
try
{
//
_bstr_t strConnectionString = "Provider=sqloledb;Server=server1;Database=db1" ;
pConnection->CursorLocation = adUseClient ;
pConnection->Open(strConnectionString,
_T("user"), _T("pwd"), -1);
_CommandPtr pCommand(__uuidof(Command));
pCommand->ActiveConnection = pConnection;
pCommand->CommandText = "MyStoreProcedure";
pCommand->CommandType = adCmdStoredProc;
_RecordsetPtr pRecordSet = pCommand->Execute( 0, 0, 0 ) ;
// This fails
long lNumRecs = pRecordSet->RecordCount ;
pRecordSet->Close();
pConnection->Close();
::CoUninitialize();
}
catch (_com_error &e)
{
::CoUninitialize();
// ...
}
Dear Chappers, I get an error also, but no solution, sorry
Ado.cpp
h:\src\alarmlogger_vc2005\alarmview\debugobj\msado15.tli(111) : error C2065: '_result' : undeclared identifier
No comments:
Post a Comment