Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. I can't find IT

I can't find IT

Scheduled Pinned Locked Moved Database
3 Posts 2 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bigge
    wrote on last edited by
    #1

    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

    R 1 Reply Last reply
    0
    • B 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

      R Offline
      R Offline
      Rashid Thadha
      wrote on last edited by
      #2

      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.

      B 1 Reply Last reply
      0
      • R Rashid Thadha

        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.

        B Offline
        B Offline
        Bigge
        wrote on last edited by
        #3

        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);

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups