I can't find IT
-
This code aint working and i dont no why, anyone who can look at it an see i they find somesthing wrong. The Procedure is: Create procedure AdoTestA" (@pkMbtID varchar(50))" as INSERT INTO MBT (pkMbtID, MbtType) Values (@pkMbtID, '122') return The Code: _bstr_t bstr (L"Provider=SQLOLEDB.1; Data Source=M02WS-17-051;Initial Catalog=TEMC_MEASSQL;uid=sa"); pCon.CreateInstance(__uuidof(ADODB::Connection)); pCommand.CreateInstance(__uuidof(ADODB::Command)); Con->Open(bstr, (BSTR)NULL, (BSTR)NULL, -1); pCommand->ActiveConnection = pCon; pCommand->CommandText = bstrSP; pCommand->CommandType = ADODB::adCmdStoredProc; pCommand->Parameters->Append(pCommand->CreateParameter( L"@pkMbtID",ADODB::adVarChar, ADODB::adParamInput, 50, _variant_t("Smith"))); _variant_t vNull; vNull.vt = VT_ERROR; vNull.scode = DISP_E_PARAMNOTFOUND; pCommand->Execute( &vNull, &vNull, ADODB::adCmdUnknown); I can compile it but when execute it say abnormal program..... MVH Bigge
-
This code aint working and i dont no why, anyone who can look at it an see i they find somesthing wrong. The Procedure is: Create procedure AdoTestA" (@pkMbtID varchar(50))" as INSERT INTO MBT (pkMbtID, MbtType) Values (@pkMbtID, '122') return The Code: _bstr_t bstr (L"Provider=SQLOLEDB.1; Data Source=M02WS-17-051;Initial Catalog=TEMC_MEASSQL;uid=sa"); pCon.CreateInstance(__uuidof(ADODB::Connection)); pCommand.CreateInstance(__uuidof(ADODB::Command)); Con->Open(bstr, (BSTR)NULL, (BSTR)NULL, -1); pCommand->ActiveConnection = pCon; pCommand->CommandText = bstrSP; pCommand->CommandType = ADODB::adCmdStoredProc; pCommand->Parameters->Append(pCommand->CreateParameter( L"@pkMbtID",ADODB::adVarChar, ADODB::adParamInput, 50, _variant_t("Smith"))); _variant_t vNull; vNull.vt = VT_ERROR; vNull.scode = DISP_E_PARAMNOTFOUND; pCommand->Execute( &vNull, &vNull, ADODB::adCmdUnknown); I can compile it but when execute it say abnormal program..... MVH Bigge
put some exception handling round it, atleast this way it won't crash the program try { } catch(_com_error e) { TRACE("Erroe %s", (LPCSTR)e.description()); } catch(...) { } also instead of using &vNull, use vtMissing variable which is define in the ado headers.
-
put some exception handling round it, atleast this way it won't crash the program try { } catch(_com_error e) { TRACE("Erroe %s", (LPCSTR)e.description()); } catch(...) { } also instead of using &vNull, use vtMissing variable which is define in the ado headers.
From now I will always use "Try and catch" even with small and simple ADO connections, i found the problem. Thanks Rashid This was very useful: catch( _com_error &e){ _bstr_t bstrSource(e.Source()); _bstr_t bs = _bstr_t(" Error: ") + _bstr_t(e.Error()) + _bstr_t(" Msg: ") + _bstr_t(e.ErrorMessage()) + _bstr_t(" Description: ") + _bstr_t(e.Description()); MessageBox(0,bs,bstrSource, MB_OK);