Click here to Skip to main content
15,888,238 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Disabling pasting on a edit control Pin
Gavin Taylor14-Feb-08 5:46
professionalGavin Taylor14-Feb-08 5:46 
GeneralRe: Disabling pasting on a edit control Pin
David Crow14-Feb-08 9:47
David Crow14-Feb-08 9:47 
GeneralRe: Disabling pasting on a edit control Pin
Rajesh R Subramanian14-Feb-08 20:35
professionalRajesh R Subramanian14-Feb-08 20:35 
GeneralRe: Disabling pasting on a edit control Pin
Maxwell Chen14-Feb-08 21:42
Maxwell Chen14-Feb-08 21:42 
GeneralRe: Disabling pasting on a edit control Pin
Iain Clarke, Warrior Programmer14-Feb-08 22:34
Iain Clarke, Warrior Programmer14-Feb-08 22:34 
GeneralCDatabase - Knowing table count and table names from database. Pin
Aamol M14-Feb-08 4:26
Aamol M14-Feb-08 4:26 
GeneralRe: CDatabase - Knowing table count and table names from database. Pin
Mark Salsbery14-Feb-08 7:38
Mark Salsbery14-Feb-08 7:38 
GeneralRe: CDatabase - Knowing table count and table names from database. Pin
Mark Salsbery14-Feb-08 7:45
Mark Salsbery14-Feb-08 7:45 
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::Open(UINT nOpenType, LPCTSTR lpszSQL, DWORD /*dwOptions*/)
{
	ASSERT(lpszSQL == NULL);
	lpszSQL;
	RETCODE nRetCode;

	// Cache state info and allocate hstmt
	SetState(nOpenType,NULL,noDirtyFieldCheck);
	if (!AllocHstmt())
		return FALSE;

	TRY
	{
		OnSetOptions(m_hstmt);
		AllocStatusArrays();

		// call the ODBC catalog function with data member params
#if defined(_UNICODE)
		AFX_SQL_ASYNC(this, (::SQLTables)(m_hstmt,
			(m_strQualifierParam.IsEmpty()? NULL: (SQLTCHAR *)(const wchar_t *)m_strQualifierParam), 
			SQL_NTS,
			(m_strOwnerParam.IsEmpty()? NULL: (SQLTCHAR *)(const wchar_t *)m_strOwnerParam), 
			SQL_NTS,
			(m_strNameParam.IsEmpty()? NULL: (SQLTCHAR *)(const wchar_t *)m_strNameParam), 
			SQL_NTS,
			(m_strTypeParam.IsEmpty()? NULL: (SQLTCHAR *)(const wchar_t *)m_strTypeParam), 
			SQL_NTS));
#else
		AFX_SQL_ASYNC(this, (::SQLTables)(m_hstmt,
			(m_strQualifierParam.IsEmpty()? (UCHAR FAR *)NULL: (UCHAR FAR *)(const char*)m_strQualifierParam), 
			SQL_NTS,
			(m_strOwnerParam.IsEmpty()? (UCHAR FAR *)NULL: (UCHAR FAR *)(const char*)m_strOwnerParam), 
			SQL_NTS,
			(m_strNameParam.IsEmpty()? (UCHAR FAR *)NULL: (UCHAR FAR *)(const char*)m_strNameParam), 
			SQL_NTS,
			(m_strTypeParam.IsEmpty()? (UCHAR FAR *)NULL: (UCHAR FAR *)(const char*)m_strTypeParam), 
			SQL_NTS));
#endif
		if (!Check(nRetCode))
			ThrowDBException(nRetCode, m_hstmt);

		// Allocate memory and cache info
		AllocAndCacheFieldInfo();
		AllocRowset();

		// Fetch the first row of data
		MoveNext();

		// If EOF, result set is empty, set BOF as well
		m_bBOF = m_bEOF;
	}

	CATCH_ALL(e)
	{
		Close();
		THROW_LAST();
	}
	END_CATCH_ALL

	return TRUE;
}

CString CTablesTable::GetDefaultConnect()
{
	return _T("ODBC;");
}

CString CTablesTable::GetDefaultSQL()
{
	// should SQLTables directly, so GetSQL should never be called
	ASSERT(FALSE);
	return _T("!");
}

void CTablesTable::DoFieldExchange(CFieldExchange* pFX)
{
	//{{AFX_FIELD_MAP(CTablesTable)
	pFX->SetFieldType(CFieldExchange::outputColumn);
	RFX_Text(pFX, _T("table_qualifier"), m_strQualifier);
	RFX_Text(pFX, _T("table_owner"), m_strOwner);
	RFX_Text(pFX, _T("table_name"), m_strTableName);
	RFX_Text(pFX, _T("table_type"), m_strTableType);
	RFX_Text(pFX, _T("remarks"), m_strRemarks);
	//}}AFX_FIELD_MAP
}
Mark






Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

QuestionAdding Controls in CGridCtrl virtual mode Pin
Rajith14-Feb-08 2:12
Rajith14-Feb-08 2:12 
GeneralRe: Adding Controls in CGridCtrl virtual mode Pin
Iain Clarke, Warrior Programmer14-Feb-08 22:52
Iain Clarke, Warrior Programmer14-Feb-08 22:52 
GeneralDCOM configuration Pin
George_George14-Feb-08 2:00
George_George14-Feb-08 2:00 
GeneralRe: DCOM configuration Pin
Matthew Faithfull14-Feb-08 2:57
Matthew Faithfull14-Feb-08 2:57 
GeneralRe: DCOM configuration Pin
George_George14-Feb-08 3:04
George_George14-Feb-08 3:04 
GeneralRe: DCOM configuration Pin
Matthew Faithfull14-Feb-08 3:10
Matthew Faithfull14-Feb-08 3:10 
GeneralRe: DCOM configuration Pin
George_George14-Feb-08 3:36
George_George14-Feb-08 3:36 
GeneralLogonUser Failing Pin
Leoinlove14-Feb-08 1:36
Leoinlove14-Feb-08 1:36 
QuestionRe: LogonUser Failing Pin
David Crow14-Feb-08 9:57
David Crow14-Feb-08 9:57 
GeneralRe: LogonUser Failing Pin
Leoinlove14-Feb-08 18:58
Leoinlove14-Feb-08 18:58 
Generalscanf to scanf_s Pin
Russell'13-Feb-08 23:49
Russell'13-Feb-08 23:49 
GeneralRe: scanf to scanf_s Pin
Cedric Moonen14-Feb-08 0:05
Cedric Moonen14-Feb-08 0:05 
GeneralRe: scanf to scanf_s Pin
Russell'14-Feb-08 1:33
Russell'14-Feb-08 1:33 
GeneralRe: scanf to scanf_s Pin
Cedric Moonen14-Feb-08 1:45
Cedric Moonen14-Feb-08 1:45 
GeneralRe: scanf to scanf_s Pin
Russell'14-Feb-08 2:00
Russell'14-Feb-08 2:00 
QuestionHow to comper 2 CListCtrl table with minimal complexity ? Pin
Yanshof13-Feb-08 23:12
Yanshof13-Feb-08 23:12 
QuestionListView with LargeIcon items of different sizes. Pin
Chesnokov Yuriy13-Feb-08 22:45
professionalChesnokov Yuriy13-Feb-08 22:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.