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. CDatabase - Knowing table count and table names from database.

CDatabase - Knowing table count and table names from database.

Scheduled Pinned Locked Moved C / C++ / MFC
c++databasequestion
3 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.
  • A Offline
    A Offline
    Aamol M
    wrote on last edited by
    #1

    VC++ 6.0 I am using CDatabase - for opening MDB file. Does anyone knows anything that will give me number of tables present into databse with their names? Thanks in advance :)

    AmolM

    M 2 Replies Last reply
    0
    • A Aamol M

      VC++ 6.0 I am using CDatabase - for opening MDB file. Does anyone knows anything that will give me number of tables present into databse with their names? Thanks in advance :)

      AmolM

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      I use the SQLTables() Function[^] Mark

      Mark Salsbery Microsoft MVP - Visual C++ :java:

      1 Reply Last reply
      0
      • A Aamol M

        VC++ 6.0 I am using CDatabase - for opening MDB file. Does anyone knows anything that will give me number of tables present into databse with their names? Thanks in advance :)

        AmolM

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        Here ya go...SQLTables() wrapped in a CRecordset...

        // TablesTable.h : interface of the CTablesTable class

        /////////////////////////////////////////////////////////////////////////////

        #if !defined(AFX_TABLESTABLE_H__C56C489A_652B_421F_A869_43D7E8E6D602__INCLUDED_)
        #define AFX_TABLESTABLE_H__C56C489A_652B_421F_A869_43D7E8E6D602__INCLUDED_

        #if _MSC_VER > 1000
        #pragma once
        #endif // _MSC_VER > 1000

        #ifndef __AFXWIN_H__
            #error include 'stdafx.h' before including this file for PCH
        #endif

        class CTablesTable : public CRecordset
        {
        DECLARE_DYNAMIC(CTablesTable)

        public:
            CTablesTable(CDatabase* pDatabase = NULL);

        virtual BOOL Open(UINT nOpenType = forwardOnly, LPCTSTR lpszSQL = NULL,
                DWORD dwOptions = readOnly);

        // Field/Param Data
            //{{AFX_FIELD(CTablesTable, CRecordset)
            CString m_strQualifier;
            CString m_strOwner;
            CString m_strTableName;
            CString m_strTableType;
            CString m_strRemarks;
            //}}AFX_FIELD

        CString m_strQualifierParam;
            CString m_strOwnerParam;
            CString m_strNameParam;
            CString m_strTypeParam;

        // Implementation
        protected:
            virtual CString GetDefaultConnect();    // default connection string
            virtual CString GetDefaultSQL();    // default SQL for Recordset
            virtual void DoFieldExchange(CFieldExchange* pFX);  // RFX support
        };

        #endif // !defined(AFX_TABLESTABLE_H__C56C489A_652B_421F_A869_43D7E8E6D602__INCLUDED_)

        // TablesTable.cpp : implementation of the CTablesTable class

        #include "stdafx.h"
        #include "TablesTable.h"

        #if (_MANAGED == 1)
        #pragma unmanaged
        #endif

        #ifdef _DEBUG
        #define new DEBUG_NEW
        #undef THIS_FILE
        static char THIS_FILE[] = __FILE__;
        #endif

        /////////////////////////////////////////////////////////////////////////////
        // CTablesTable implementation

        IMPLEMENT_DYNAMIC(CTablesTable, CRecordset)

        CTablesTable::CTablesTable(CDatabase* pDatabase)
        : CRecordset(pDatabase)
        {
        //{{AFX_FIELD_INIT(CTablesTable)
        m_strQualifier = _T("");
        m_strOwner = _T("");
        m_strTableName = _T("");
        m_strTableType = _T("");
        m_strRemarks = _T("");
        m_nFields = 5;
        //}}AFX_FIELD_INIT
        m_strQualifierParam = _T("");
        m_strOwnerParam = _T("");
        m_strNameParam = _T("");
        m_strTypeParam = _T("");
        }

        BOOL CTablesTable::Op

        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