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. ATL / WTL / STL
  4. Ole Db Consumer

Ole Db Consumer

Scheduled Pinned Locked Moved ATL / WTL / STL
c++databasehelpcomtutorial
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.
  • D Offline
    D Offline
    Donwangugi
    wrote on last edited by
    #1

    **I am trying to create an Ole DB Consumer in order to access data from a table for a conduit application. The problem is that whenever I use the wizard to generate the code it does not generate the data members needed to correspond to the columns of the table I wish to work with. Do yo have any idea why this would happen? I can show you an example I saw on another website. Using the wizard with a table called Authors generates the code: // code generated on Wednesday, April 17, 2002, 10:25 AM

    class CAuthorsAccessor
    {
    public:
    ** LONG m_Au_ID;
    TCHAR m_Author[51];
    SHORT m_YearBorn;**

    // The following wizard-generated data members contain status
    // values for the corresponding fields in the column map. You
    // can use these values to hold NULL values that the database
    // returns or to hold error information when the compiler returns
    // errors. See Field Status Data Members in Wizard-Generated
    // Accessors in the Visual C++ documentation for more information
    // on using these fields.
    // NOTE: You must initialize these fields 
    //       before setting/inserting data!
    

    ** DBSTATUS m_dwAu_IDStatus;
    DBSTATUS m_dwAuthorStatus;
    DBSTATUS m_dwYearBornStatus;**

    // The following wizard-generated data members contain length
    // values for the corresponding fields in the column map.
    // NOTE: For variable-length columns, you must initialize these
    //       fields before setting/inserting data!
    
    DBLENGTH m\_dwAu\_IDLength;
    DBLENGTH m\_dwAuthorLength;
    DBLENGTH m\_dwYearBornLength;
    
    void GetRowsetProperties(CDBPropSet\* pPropSet)
    {
        pPropSet->AddProperty(DBPROP\_CANFETCHBACKWARDS, 
            true, DBPROPOPTIONS\_OPTIONAL);
        pPropSet->AddProperty(DBPROP\_CANSCROLLBACKWARDS, 
            true, DBPROPOPTIONS\_OPTIONAL);        
        pPropSet->AddProperty(DBPROP\_IRowsetChange, 
            true, DBPROPOPTIONS\_OPTIONAL);
        pPropSet->AddProperty(DBPROP\_UPDATABILITY, 
            DBPROPVAL\_UP\_CHANGE | DBPROPVAL\_UP\_INSERT 
            | DBPROPVAL\_UP\_DELETE);
    }
    HRESULT OpenDataSource()
    {
        CDataSource \_db;
        HRESULT hr;
        // Here goes the \_db.OpenFromInitializationString
        
        if (FAILED(hr))
        {
    

    #ifdef _DEBUG
    AtlTraceErrorRecords(hr);
    #endif
    return hr;
    }
    return m_session.Open(_db);
    }

    void CloseDataSource()
    {
        m\_session.Close();
    }**
    
    G 1 Reply Last reply
    0
    • D Donwangugi

      **I am trying to create an Ole DB Consumer in order to access data from a table for a conduit application. The problem is that whenever I use the wizard to generate the code it does not generate the data members needed to correspond to the columns of the table I wish to work with. Do yo have any idea why this would happen? I can show you an example I saw on another website. Using the wizard with a table called Authors generates the code: // code generated on Wednesday, April 17, 2002, 10:25 AM

      class CAuthorsAccessor
      {
      public:
      ** LONG m_Au_ID;
      TCHAR m_Author[51];
      SHORT m_YearBorn;**

      // The following wizard-generated data members contain status
      // values for the corresponding fields in the column map. You
      // can use these values to hold NULL values that the database
      // returns or to hold error information when the compiler returns
      // errors. See Field Status Data Members in Wizard-Generated
      // Accessors in the Visual C++ documentation for more information
      // on using these fields.
      // NOTE: You must initialize these fields 
      //       before setting/inserting data!
      

      ** DBSTATUS m_dwAu_IDStatus;
      DBSTATUS m_dwAuthorStatus;
      DBSTATUS m_dwYearBornStatus;**

      // The following wizard-generated data members contain length
      // values for the corresponding fields in the column map.
      // NOTE: For variable-length columns, you must initialize these
      //       fields before setting/inserting data!
      
      DBLENGTH m\_dwAu\_IDLength;
      DBLENGTH m\_dwAuthorLength;
      DBLENGTH m\_dwYearBornLength;
      
      void GetRowsetProperties(CDBPropSet\* pPropSet)
      {
          pPropSet->AddProperty(DBPROP\_CANFETCHBACKWARDS, 
              true, DBPROPOPTIONS\_OPTIONAL);
          pPropSet->AddProperty(DBPROP\_CANSCROLLBACKWARDS, 
              true, DBPROPOPTIONS\_OPTIONAL);        
          pPropSet->AddProperty(DBPROP\_IRowsetChange, 
              true, DBPROPOPTIONS\_OPTIONAL);
          pPropSet->AddProperty(DBPROP\_UPDATABILITY, 
              DBPROPVAL\_UP\_CHANGE | DBPROPVAL\_UP\_INSERT 
              | DBPROPVAL\_UP\_DELETE);
      }
      HRESULT OpenDataSource()
      {
          CDataSource \_db;
          HRESULT hr;
          // Here goes the \_db.OpenFromInitializationString
          
          if (FAILED(hr))
          {
      

      #ifdef _DEBUG
      AtlTraceErrorRecords(hr);
      #endif
      return hr;
      }
      return m_session.Open(_db);
      }

      void CloseDataSource()
      {
          m\_session.Close();
      }**
      
      G Offline
      G Offline
      Gene OK
      wrote on last edited by
      #2

      I had the same problem when trying to use Ole DB in a ATL application. The wizard would not generate any columns. I never determined what caused the problem. I eventually had to reinstall VS 2005 and it started working.

      CodeWiz51 -- Life is not a spectator sport. I came to play. Code's Musings | Code's Articles

      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