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. General Programming
  3. C / C++ / MFC
  4. ADO exception problem

ADO exception problem

Scheduled Pinned Locked Moved C / C++ / MFC
databasehelpcomquestion
5 Posts 3 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.
  • U Offline
    U Offline
    unknown soldier
    wrote on last edited by
    #1

    I am writing a simple DOS applicaion that is using ADO to connect to data source. The COM libraries are initializing successfully and the connection to database by connection pointer is also established. But when i try to run a "query" using connection pointer, the following exception is raised:

    Error:800a0e81.
    ErrorMessage:Unknown error 0x800A0E81.
    Source:ADODB.Connection.
    Description:Operation cannot be performed while connecting asynchronously..

    Can any one tell me why this happens ??? Here is my code:

    \_bstr\_t bstrQuery("SELECT \* FROM Customers");
    \_variant\_t vRecsAffected(0L);
    \_RecordsetPtr pRecordSet;
    

    pRecordSet = m_pConnection->Execute(bstrQuery, &vRecsAffected, adOptionUnspecified);

    R L 2 Replies Last reply
    0
    • U unknown soldier

      I am writing a simple DOS applicaion that is using ADO to connect to data source. The COM libraries are initializing successfully and the connection to database by connection pointer is also established. But when i try to run a "query" using connection pointer, the following exception is raised:

      Error:800a0e81.
      ErrorMessage:Unknown error 0x800A0E81.
      Source:ADODB.Connection.
      Description:Operation cannot be performed while connecting asynchronously..

      Can any one tell me why this happens ??? Here is my code:

      \_bstr\_t bstrQuery("SELECT \* FROM Customers");
      \_variant\_t vRecsAffected(0L);
      \_RecordsetPtr pRecordSet;
      

      pRecordSet = m_pConnection->Execute(bstrQuery, &vRecsAffected, adOptionUnspecified);

      R Offline
      R Offline
      RChin
      wrote on last edited by
      #2

      Just a stab in the dark, but you might need to create an instance of the Recordset object_RecordsetPtr pRecordset = NULL; // Create COM instance. You should also test the return code for // this for success. pRecordset.CreateInstance(__uuidof(Recordset)); // // etc. etc..
      chin

      U 1 Reply Last reply
      0
      • R RChin

        Just a stab in the dark, but you might need to create an instance of the Recordset object_RecordsetPtr pRecordset = NULL; // Create COM instance. You should also test the return code for // this for success. pRecordset.CreateInstance(__uuidof(Recordset)); // // etc. etc..
        chin

        U Offline
        U Offline
        unknown soldier
        wrote on last edited by
        #3

        Not worked

        R 1 Reply Last reply
        0
        • U unknown soldier

          I am writing a simple DOS applicaion that is using ADO to connect to data source. The COM libraries are initializing successfully and the connection to database by connection pointer is also established. But when i try to run a "query" using connection pointer, the following exception is raised:

          Error:800a0e81.
          ErrorMessage:Unknown error 0x800A0E81.
          Source:ADODB.Connection.
          Description:Operation cannot be performed while connecting asynchronously..

          Can any one tell me why this happens ??? Here is my code:

          \_bstr\_t bstrQuery("SELECT \* FROM Customers");
          \_variant\_t vRecsAffected(0L);
          \_RecordsetPtr pRecordSet;
          

          pRecordSet = m_pConnection->Execute(bstrQuery, &vRecsAffected, adOptionUnspecified);

          L Offline
          L Offline
          Le centriste
          wrote on last edited by
          #4

          This code must be incomplete. We don't see the code for creating the Connection object. Also, you may want to work only with the recordset object, unless you want to reuse the connection for other queries. Michel It is a lovely language, but it takes a very long time to say anything in it, because we do not say anything in it, unless it is worth taking a very long time to say, and to listen to.
          - TreeBeard

          1 Reply Last reply
          0
          • U unknown soldier

            Not worked

            R Offline
            R Offline
            RChin
            wrote on last edited by
            #5

            Your original error message mentions something about an asyncronous connection. This may be the root of all your evils :mad: An asyncronous ADO connection requires a lot more construction code that your entire program may be missing. I have done a quick test and it seems to work ok. I've provided the console function below for you to look at. void ConnectAndDisplay() { CString strSQL; // SQL statement string _variant_t vtAffected; // _variant_t vtField; // _ConnectionPtr pConnection = NULL; // connection smart pointer _RecordsetPtr pRecordset = NULL; // recordset smart pointer strSQL = "Select [Name] From [CustomerTable]"; try { TESTHR( pConnection.CreateInstance(__uuidof(Connection)) ); TESTHR( pRecordset.CreateInstance(__uuidof(Recordset)) ); TESTHR( pConnection->Open( _bstr_t(_T("File \\MyConnection.udl;")), "", "", NULL ) ); // Execute pre-prepared SQL statement pRecordset = pConnection->Execute((LPCTSTR)strSQL, &vtAffected,adOptionUnspecified); // display returned results while( pRecordset->ADOEOF != VARIANT_TRUE ) { _variant_t vtField; CString strField; vtField = pRecordset->Fields->GetItem("Name")->Value; ///////////////////////////////////////// ASSERT( vtField.vt == VT_BSTR ); // we are expecting a string!! //////////////////////////////////////// strField = vtField.bstrVal; cout<< (LPCTSTR)strField << endl; pRecordset->MoveNext(); } pConnection->Close(); } catch(_com_error e) { CString strMessage; strMessage.Format("Error: %s\n", e.ErrorMessage()); AfxMessageBox(strMessage); } return; } Chin

            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