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. Automation Error

Automation Error

Scheduled Pinned Locked Moved Database
databasewpfwcfsysadmintesting
2 Posts 2 Posters 0 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
    bugbuster
    wrote on last edited by
    #1

    Hi everyone, I'm having trouble with an Access query. My program does one connection to the db and several queries, but only the first one is going through, the second one throws Error '-2147417851 (8001015)' which is an automation error. I'v searched for the cause and it says it's because the server is throwing an exception. I read in Microsoft's support site and found out that I need to do late binding, but I believe that's what I'm doing. The code is this: int CDBAccess::cargaConfig(char *pszComponente, CConfig *poConfig) { _RecordsetPtr rs; HRESULT hr; _variant_t conn; char szQuery[256]; char szTemp[30]; FieldPtr campo; try { hr = rs.CreateInstance("ADODB.Recordset"); if(FAILED(hr)) { m_nError = 506;//error al crear rs return m_nError; } conn = (IDispatch*) m_Conec; } catch(_com_error & err) { MessageBox(NULL,(LPCTSTR) err.Description(), "CargaConfig", MB_OK); return -1; } //se hace el query sprintf(szQuery, "select * from configuracion where componente = '%s'", pszComponente); _bstr_t qry(szQuery); FILE *fd; fd = fopen("C:\\usr\\sia\\query.txt","w"); fprintf(fd,"%s",(char *)qry); fclose(fd); //MessageBox(NULL,(char *)qry, "cargaConfig",0); try { hr = rs->Open(qry, conn, adOpenStatic, adLockOptimistic, adCmdText); if(FAILED(hr)) { m_nError = 507;//error al abrir rs return m_nError; } } catch(_com_error & err) { MessageBox(NULL,(LPCTSTR) err.Description(), "CargaConfig", MB_OK); return -1; } try { //se leen los datos campo = rs->Fields->Item["timeout"]; _bstr_t to = campo->Value; sprintf(szTemp, "%s", (char *)to); poConfig->iTimeout = atoi(szTemp); campo = rs->Fields->Item["canal_comunicacion"]; _bstr_t can = campo->Value; sprintf(poConfig->szCanalComm, "%s", (char *)can); campo = rs->Fields->Item["id_canal"]; _bstr_t idcan = campo->Value; sprintf(poConfig->szIdCanal, "%s", (char *)idcan); campo = rs->Fields->Item["objeto"]; _bstr_t obj = campo->Value; sprintf(poConfig->szObjeto, "%s", (char *)obj); campo = rs->Fields->Item["prioridad"]; _bstr_t pri = campo->Value; sprintf(poConfig->szPriori, "%s", (char *)pri); hr = rs->Close(); if(FAILED(hr)) { m_nError = 508;//error al cerrar rs return m_nError; } //rs = NULL; } catch(_com_error & err) { MessageBox(NULL,(LPCTSTR)err.Description(),"CargaConfig",0); return -1; }

    N 1 Reply Last reply
    0
    • B bugbuster

      Hi everyone, I'm having trouble with an Access query. My program does one connection to the db and several queries, but only the first one is going through, the second one throws Error '-2147417851 (8001015)' which is an automation error. I'v searched for the cause and it says it's because the server is throwing an exception. I read in Microsoft's support site and found out that I need to do late binding, but I believe that's what I'm doing. The code is this: int CDBAccess::cargaConfig(char *pszComponente, CConfig *poConfig) { _RecordsetPtr rs; HRESULT hr; _variant_t conn; char szQuery[256]; char szTemp[30]; FieldPtr campo; try { hr = rs.CreateInstance("ADODB.Recordset"); if(FAILED(hr)) { m_nError = 506;//error al crear rs return m_nError; } conn = (IDispatch*) m_Conec; } catch(_com_error & err) { MessageBox(NULL,(LPCTSTR) err.Description(), "CargaConfig", MB_OK); return -1; } //se hace el query sprintf(szQuery, "select * from configuracion where componente = '%s'", pszComponente); _bstr_t qry(szQuery); FILE *fd; fd = fopen("C:\\usr\\sia\\query.txt","w"); fprintf(fd,"%s",(char *)qry); fclose(fd); //MessageBox(NULL,(char *)qry, "cargaConfig",0); try { hr = rs->Open(qry, conn, adOpenStatic, adLockOptimistic, adCmdText); if(FAILED(hr)) { m_nError = 507;//error al abrir rs return m_nError; } } catch(_com_error & err) { MessageBox(NULL,(LPCTSTR) err.Description(), "CargaConfig", MB_OK); return -1; } try { //se leen los datos campo = rs->Fields->Item["timeout"]; _bstr_t to = campo->Value; sprintf(szTemp, "%s", (char *)to); poConfig->iTimeout = atoi(szTemp); campo = rs->Fields->Item["canal_comunicacion"]; _bstr_t can = campo->Value; sprintf(poConfig->szCanalComm, "%s", (char *)can); campo = rs->Fields->Item["id_canal"]; _bstr_t idcan = campo->Value; sprintf(poConfig->szIdCanal, "%s", (char *)idcan); campo = rs->Fields->Item["objeto"]; _bstr_t obj = campo->Value; sprintf(poConfig->szObjeto, "%s", (char *)obj); campo = rs->Fields->Item["prioridad"]; _bstr_t pri = campo->Value; sprintf(poConfig->szPriori, "%s", (char *)pri); hr = rs->Close(); if(FAILED(hr)) { m_nError = 508;//error al cerrar rs return m_nError; } //rs = NULL; } catch(_com_error & err) { MessageBox(NULL,(LPCTSTR)err.Description(),"CargaConfig",0); return -1; }

      N Offline
      N Offline
      notadood
      wrote on last edited by
      #2

      Is this the second query that is failing? It looks like your syntax is for SQL Server, using wildcard %. If you are trying to wildcard it, and you are using Access your query needs to say: select * from configuracion where componente like '*s' Otherwise the query will never return any records.

      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