Hello, NG
I have following problem.
In the line pRs->Open(rsString, &pCon, adOpenForwardOnly, adLockReadOnly,
adCmdUnknown);
it goes in the catch function mit the message:
Code=800s0bb9 Msg: Unknown error 0x800A0BB9 Source: ADODB.Recordset
Description: Arguments are of the wrong type, are out of acceptable range,
or are in conflict with one another.
The SQL String works with the SQL Enterprise Manager
Help me!!!
Here´s the code
void CAdoTestDlg::OnGetProductType()
{
char *ProductType;
char *SeriaNumber;
try
{
_ConnectionPtr pCon = NULL;
_RecordsetPtr pRs = NULL;
FieldPtr pfldFirstName, pfldLastName, pfldAge;
_variant_t vFirstName, vLastName, vAge;
_bstr_t bsEmpty = L"";
// Create and set pCon structure
pCon.CreateInstance(__uuidof(Connection));
pCon->Provider = "SQLOLEDB";
pCon->CommandTimeout = 3;
// Define and set connection string
_bstr_t cnnString = "DATA SOURCE='Server1';USER ID='xxx';PASSWORD='xxx';";
pCon->ConnectionString = cnnString;
pCon->CursorLocation = adUseClient;
pCon->ConnectionTimeout = 1;
pCon->Open(bsEmpty, bsEmpty, bsEmpty, adConnectUnspecified);
long test1=0;
test1 = pCon->State; //test1=1 O.K.
// Create and set pRs structure
pRs.CreateInstance(__uuidof(Recordset));
pRs->PutRefActiveConnection( pCon );
// Open the record set and retrieve the data
_bstr_t rsString = "SELECT datum,identnummer,etext FROM protokoll WHERE
identnummer = '14090984' order by datum desc";
pRs->Open(rsString, &pCon, adOpenForwardOnly, adLockReadOnly,
adCmdUnknown); //hier springt er in die Catchfunktion
int rstFound = pRs->RecordCount;
// Close connections
pRs->Close();
pCon->Close();
}
catch( _com_error &e )
{
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
CString str;
str.Format("\tCode = %08lx", e.Error());
str += " Msg: "; str += e.ErrorMessage();
str += " Source: "; str += bstrSource;
str += " Description: "; str += bstrDescription;
AfxMessageBox(str);
}
Thanks, Marcus