首先参照另一篇http://blog.csdn.net/etwdone/article/details/8484206建立MFC与数据库的连接
接着创见如下界面
接着直接将头文件和CPP放上
ClerkMDlg.h
#pragma once
#include "stdafx.h"
#include "Library.h"
#include "afxdialogex.h"
#include "MainFrm.h"
// CClerkMDlg 对话框
class CClerkMDlg : public CDialog
{
DECLARE_DYNAMIC(CClerkMDlg)
public:
CClerkMDlg(CWnd* pParent = NULL); // 标准构造函数
virtual ~CClerkMDlg();
_RecordsetPtr pRst,p,pfirst,plast,pp;
//CoInitialize(NULL);
//_RecordsetPtr pRst(Recordset);
// 对话框数据
enum { IDD = IDD_DIALOG1 };
CString m_strUserNameQ;
CString m_strUserNameQQ;
CString m_strUserIDQ;
CString m_strUserID;
CString m_strUserName;
CString m_strPassWord;
CString m_strIDCard;
bool sts;
void DisplayRecord(_RecordsetPtr pRst );
BOOL OnInitDialog();
void SetTextSate();
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
DECLARE_MESSAGE_MAP()
public:
afx_msg void OnBnClickedFirst();
afx_msg void OnBnClickedLast();
afx_msg void OnBnClickedPrior();
afx_msg void OnBnClickedNest();
afx_msg void OnBnClickedNew();
afx_msg void OnBnClickedEdit();
afx_msg void OnBnClickedEnquery();
afx_msg void OnBnClickedDelete();
afx_msg void OnBnClickedSave();
afx_msg void OnBnClickedCancelRec();
afx_msg void OnBnClickedExit();
};
ClerkMDlg.cpp
// ClerkMDlg.cpp : 实现文件
//
#include "stdafx.h"
#include "Library.h"
#include "ClerkMDlg.h"
#include "afxdialogex.h"
#include "MainFrm.h"
// CClerkMDlg 对话框
IMPLEMENT_DYNAMIC(CClerkMDlg, CDialog)
CClerkMDlg::CClerkMDlg(CWnd* pParent /*=NULL*/)
: CDialog(CClerkMDlg::IDD, pParent)
{
m_strUserNameQ = _T("");
m_strUserName = _T("");
m_strUserIDQ = _T("");
m_strUserID = _T("");
m_strPassWord = _T("");
m_strIDCard = _T("");
sts=true;
p=NULL;
pfirst=NULL;
plast=NULL;
pp=NULL;
//_RecordsetPtr pRst(__uuidof(Recor