⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 apb.htm

📁 21精通SQL
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>

<HEAD>
	
	<TITLE>Teach Yourself SQL in 21 Days, Second Edition -- Appendix B -- Source Code Listings for the C++ Program Used on Day 14</TITLE>
</HEAD>

<BODY TEXT="#000000" BGCOLOR="#FFFFFF">

<CENTER>
<H1><IMG SRC="sams.gif" tppabs="http://202.113.16.101/%7eeb%7e/Teach%20Yourself%20MS%20SQL%20Server%206.5%20in%2021%20Days/sams.gif" WIDTH="171" HEIGHT="66" ALIGN="BOTTOM" BORDER="0"><BR>
<FONT COLOR="#000077">Teach Yourself SQL in 21 Days, Second Edition</FONT></H1>
</CENTER>
<CENTER>
<P><A HREF="apa.htm" tppabs="http://202.113.16.101/%7eeb%7e/Teach%20Yourself%20MS%20SQL%20Server%206.5%20in%2021%20Days/apa.htm"><IMG SRC="previous.gif" tppabs="http://202.113.16.101/%7eeb%7e/Teach%20Yourself%20MS%20SQL%20Server%206.5%20in%2021%20Days/previous.gif" WIDTH="128" HEIGHT="28"
ALIGN="BOTTOM" ALT="Previous chapter" BORDER="0"></A><A HREF="apc.htm" tppabs="http://202.113.16.101/%7eeb%7e/Teach%20Yourself%20MS%20SQL%20Server%206.5%20in%2021%20Days/apc.htm"><IMG
SRC="next.gif" tppabs="http://202.113.16.101/%7eeb%7e/Teach%20Yourself%20MS%20SQL%20Server%206.5%20in%2021%20Days/next.gif" WIDTH="128" HEIGHT="28" ALIGN="BOTTOM" ALT="Next chapter"
BORDER="0"></A><A HREF="index-1.htm" tppabs="http://202.113.16.101/%7eeb%7e/Teach%20Yourself%20MS%20SQL%20Server%206.5%20in%2021%20Days/index-1.htm"><IMG SRC="contents.gif" tppabs="http://202.113.16.101/%7eeb%7e/Teach%20Yourself%20MS%20SQL%20Server%206.5%20in%2021%20Days/contents.gif" WIDTH="128"
HEIGHT="28" ALIGN="BOTTOM" ALT="Contents" BORDER="0"></A> 
<HR>

</CENTER>
<CENTER>
<H1><FONT COLOR="#000077">- Appendix B -<BR>
Source Code Listings for the C++ Program Used on Day 14</FONT></H1>
</CENTER>
<PRE><FONT COLOR="#0066FF">

// tyssqvw.h : interface of the CTyssqlView class
//
/////////////////////////////////////////////////////////////////////////////

class CTyssqlSet;

class CTyssqlView : public CRecordView
{
protected: // create from serialization only
    CTyssqlView();
    DECLARE_DYNCREATE(CTyssqlView)

public:
    //{{AFX_DATA(CTyssqlView)
    enum { IDD = IDD_TYSSQL_FORM };
    CTyssqlSet* m_pSet;
    //}}AFX_DATA

// Attributes
public:
    CTyssqlDoc* GetDocument();

// Operations
public:
    virtual CRecordset* OnGetRecordset();

// Implementation
public:
    virtual ~CTyssqlView();
#ifdef _DEBUG
    virtual void AssertValid() const;
    virtual void Dump(CDumpContext&amp; dc) const;
#endif

protected:
    virtual void DoDataExchange(CDataExchange* pDX);// DDX/DDV support
    virtual void OnInitialUpdate(); // called first time after construct

// Generated message map functions
protected:
    //{{AFX_MSG(CTyssqlView)
        // NOTE - the ClassWizard will add and remove member functions here.
        //    DO NOT EDIT what you see in these blocks of generated code !
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
};

#ifndef _DEBUG  // debug version in tyssqvw.cpp
inline CTyssqlDoc* CTyssqlView::GetDocument()
   { return (CTyssqlDoc*)m_pDocument; }
#endif

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

// tyssql.h : main header file for the TYSSQL application
//

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

#include &quot;resource.h&quot;       // main symbols

/////////////////////////////////////////////////////////////////////////////
// CTyssqlApp:
// See tyssql.cpp for the implementation of this class
//

class CTyssqlApp : public CWinApp
{
public:
    CTyssqlApp();

// Overrides
    virtual BOOL InitInstance();

// Implementation

    //{{AFX_MSG(CTyssqlApp)
    afx_msg void OnAppAbout();
        // NOTE - the ClassWizard will add and remove member functions here.
        //    DO NOT EDIT what you see in these blocks of generated code !
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
};


/////////////////////////////////////////////////////////////////////////////
// tyssqset.h : interface of the CTyssqlSet class
//
/////////////////////////////////////////////////////////////////////////////

class CTyssqlSet : public CRecordset
{
DECLARE_DYNAMIC(CTyssqlSet)

public:
    CTyssqlSet(CDatabase* pDatabase = NULL);

// Field/Param Data
    //{{AFX_FIELD(CTyssqlSet, CRecordset)
    CString    m_NAME;
    CString    m_ADDRESS;
    CString    m_STATE;
    CString    m_ZIP;
    CString    m_PHONE;
    CString    m_REMARKS;
    //}}AFX_FIELD

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

// tyssqdoc.h : interface of the CTyssqlDoc class
//
/////////////////////////////////////////////////////////////////////////////

class CTyssqlDoc : public CDocument
{
protected: // create from serialization only
    CTyssqlDoc();
    DECLARE_DYNCREATE(CTyssqlDoc)

// Attributes
public:
    CTyssqlSet m_tyssqlSet;

// Operations
public:

// Implementation
public:
    virtual ~CTyssqlDoc();
#ifdef _DEBUG
    virtual void AssertValid() const;
    virtual void Dump(CDumpContext&amp; dc) const;
#endif

protected:
    virtual BOOL OnNewDocument();

// Generated message map functions
protected:
    //{{AFX_MSG(CTyssqlDoc)
        // NOTE - the ClassWizard will add and remove member functions here.
        //    DO NOT EDIT what you see in these blocks of generated code !
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////
// stdafx.h : include file for standard system include files,
//  or project specific include files that are used frequently, but
//      are changed infrequently
//

#include &lt;afxwin.h&gt;         // MFC core and standard components
#include &lt;afxext.h&gt;         // MFC extensions (including VB)
#include &lt;afxdb.h&gt;          // MFC database classes

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

//{{NO_DEPENDENCIES}}
// App Studio generated include file.
// Used by TYSSQL.RC
//
#define IDR_MAINFRAME                   2
#define IDD_ABOUTBOX                    100
#define IDD_TYSSQL_FORM                 101
#define IDP_FAILED_OPEN_DATABASE        103
#define IDC_NAME                        1000
#define IDC_ADDRESS                     1001
#define IDC_STATE                       1002
#define IDC_ZIP                         1003

// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS

#define _APS_NEXT_RESOURCE_VALUE        102
#define _APS_NEXT_COMMAND_VALUE         32771
#define _APS_NEXT_CONTROL_VALUE         1004
#define _APS_NEXT_SYMED_VALUE           101
#endif
#endif

///////////////////////////////////////////////////
</FONT></PRE>

<PRE><FONT COLOR="#0066FF">// mainfrm.h : interface of the CMainFrame class
//
/////////////////////////////////////////////////////////////////////////////

class CMainFrame : public CFrameWnd
{
protected: // create from serialization only
    CMainFrame();
    DECLARE_DYNCREATE(CMainFrame)

// Attributes
public:

// Operations
public:

// Implementation
public:
    virtual ~CMainFrame();
#ifdef _DEBUG
    virtual void AssertValid() const;
    virtual void Dump(CDumpContext&amp; dc) const;
#endif

protected:  // control bar embedded members
    CStatusBar  m_wndStatusBar;
    CToolBar    m_wndToolBar;

// Generated message map functions
protected:
    //{{AFX_MSG(CMainFrame)
    afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
        // NOTE - the ClassWizard will add and remove member functions here.
        //    DO NOT EDIT what you see in these blocks of generated code!
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
};

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

// tyssqvw.cpp : implementation of the CTyssqlView class
//

#include &quot;stdafx.h&quot;
#include &quot;tyssql.h&quot;

#include &quot;tyssqset.h&quot;
#include &quot;tyssqdoc.h&quot;
#include &quot;tyssqvw.h&quot;

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

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

// CTyssqlView

IMPLEMENT_DYNCREATE(CTyssqlView, CRecordView)

BEGIN_MESSAGE_MAP(CTyssqlView, CRecordView)
    //{{AFX_MSG_MAP(CTyssqlView)
        // NOTE - the ClassWizard will add and remove mapping macros here.
        //    DO NOT EDIT what you see in these blocks of generated code!
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTyssqlView construction/destruction

CTyssqlView::CTyssqlView()
    : CRecordView(CTyssqlView::IDD)
{
    //{{AFX_DATA_INIT(CTyssqlView)
    m_pSet = NULL;
    //}}AFX_DATA_INIT
    // TODO: add construction code here
}

CTyssqlView::~CTyssqlView()
{
}

void CTyssqlView::DoDataExchange(CDataExchange* pDX)
{
    CRecordView::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CTyssqlView)
    DDX_FieldText(pDX, IDC_ADDRESS, m_pSet-&gt;m_ADDRESS, m_pSet);
    DDX_FieldText(pDX, IDC_NAME, m_pSet-&gt;m_NAME, m_pSet);
    DDX_FieldText(pDX, IDC_STATE, m_pSet-&gt;m_STATE, m_pSet);
    DDX_FieldText(pDX, IDC_ZIP, m_pSet-&gt;m_ZIP, m_pSet);
    //}}AFX_DATA_MAP
}

void CTyssqlView::OnInitialUpdate()
{
    m_pSet = &amp;GetDocument()-&gt;m_tyssqlSet;
    CRecordView::OnInitialUpdate();

}

/////////////////////////////////////////////////////////////////////////////
// CTyssqlView diagnostics

#ifdef _DEBUG
void CTyssqlView::AssertValid() const
{
    CRecordView::AssertValid();
}

void CTyssqlView::Dump(CDumpContext&amp; dc) const
{
    CRecordView::Dump(dc);
}

CTyssqlDoc* CTyssqlView::GetDocument() // non-debug version is inline
{
    ASSERT(m_pDocument-&gt;IsKindOf(RUNTIME_CLASS(CTyssqlDoc)));
    return (CTyssqlDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CTyssqlView database support

CRecordset* CTyssqlView::OnGetRecordset()
{
    return m_pSet;
}


/////////////////////////////////////////////////////////////////////////////
// CTyssqlView message handlers


// tyssqset.cpp : implementation of the CTyssqlSet class
//

#include &quot;stdafx.h&quot;
#include &quot;tyssql.h&quot;
#include &quot;tyssqset.h&quot;

/////////////////////////////////////////////////////////////////////////////
// CTyssqlSet implementation

IMPLEMENT_DYNAMIC(CTyssqlSet, CRecordset)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -