000
11.05.2004, 14:48 Uhr
MarcusG
|
Hallo ,
ich habe folgendes Problem. Ich will mit VC6 einen Wert aus einer SQL Datenbank auslesen. Der SQL String funktioniert wie angegeben wenn ich Ihn im SQL EnterpriseMangager laufen lasse. Die Verbindung zur Datenbank scheint auch zu funktionieren, jedenfalls ist meine test1 Variable=1. In der Zeile: pRs->Open(rsString, &pCon, adOpenForwardOnly, adLockReadOnly, adCmdUnknown); springt er mir jedoch in meine definierte Catchfunktion mit: 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.
Hilfe!!!
Anbei der Code:
C++: |
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); }
|
Grüße Marcus |