StudentRecordSet

// StudentRecordSet.cpp : implementation file
//

#include "stdafx.h"
#include "My.h"
#include "StudentRecordSet.h"

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

/////////////////////////////////////////////////////////////////////////////
// CStudentRecordSet

IMPLEMENT_DYNAMIC(CStudentRecordSet, CRecordset)

CStudentRecordSet::CStudentRecordSet(CDatabase* pdb)
	: CRecordset(pdb)
{
	//{{AFX_FIELD_INIT(CStudentRecordSet)
	m_ID = _T("");
	m_Name = _T("");
	m_Score = 0;
	m_nFields = 3;
	//}}AFX_FIELD_INIT
	m_nDefaultType = snapshot;
}


CString CStudentRecordSet::GetDefaultConnect()
{
	return _T("ODBC;DSN=Mytable");
}

CString CStudentRecordSet::GetDefaultSQL()
{
	return _T("[studenttable]");
}

void CStudentRecordSet::DoFieldExchange(CFieldExchange* pFX)
{
	//{{AFX_FIELD_MAP(CStudentRecordSet)
	pFX->SetFieldType(CFieldExchange::outputColumn);
	RFX_Text(pFX, _T("[ID]"), m_ID);
	RFX_Text(pFX, _T("[Name]"), m_Name);
	RFX_Int(pFX, _T("[Score]"), m_Score);
	//}}AFX_FIELD_MAP
}

/////////////////////////////////////////////////////////////////////////////
// CStudentRecordSet diagnostics

#ifdef _DEBUG
void CStudentRecordSet::AssertValid() const
{
	CRecordset::AssertValid();
}

void CStudentRecordSet::Dump(CDumpContext& dc) const
{
	CRecordset::Dump(dc);
}
#endif //_DEBUG


.h

#if !defined(AFX_STUDENTRECORDSET_H__0A2BBB79_0C30_425E_8564_42CCC65C0ADC__INCLUDED_)
#define AFX_STUDENTRECORDSET_H__0A2BBB79_0C30_425E_8564_42CCC65C0ADC__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// StudentRecordSet.h : header file
//

/////////////////////////////////////////////////////////////////////////////
// CStudentRecordSet recordset
#include <afxdb.h>//CRecordSet的头文件
class CStudentRecordSet : public CRecordset
{
public:
	CStudentRecordSet(CDatabase* pDatabase = NULL);
	DECLARE_DYNAMIC(CStudentRecordSet)

// Field/Param Data
	//{{AFX_FIELD(CStudentRecordSet, CRecordset)
	CString	m_ID;
	CString	m_Name;
	int		m_Score;
	//}}AFX_FIELD


// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CStudentRecordSet)
	public:
	virtual CString GetDefaultConnect();    // Default connection string
	virtual CString GetDefaultSQL();    // Default SQL for Recordset
	virtual void DoFieldExchange(CFieldExchange* pFX);  // RFX support
	//}}AFX_VIRTUAL

// Implementation
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_STUDENTRECORDSET_H__0A2BBB79_0C30_425E_8564_42CCC65C0ADC__INCLUDED_)


 

你可能感兴趣的:(StudentRecordSet)