CDatabase - Knowing table count and table names from database.
-
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
I use the SQLTables() Function[^] Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
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
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
#endifclass 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_FIELDCString 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 implementationIMPLEMENT_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