home *** CD-ROM | disk | FTP | other *** search
/ Mastering MFC Development / MMD.ISO / samples / c08 / querydef / qdefset.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-02-20  |  2.0 KB  |  91 lines

  1. // QueryDefSet.cpp : implementation of the CQueryDefSet class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "QueryDef.h"
  6. #include "QDefSet.h"
  7.  
  8. #include <io.h>
  9.  
  10. #ifdef _DEBUG
  11. #define new DEBUG_NEW
  12. #undef THIS_FILE
  13. static char THIS_FILE[] = __FILE__;
  14. #endif
  15.  
  16. /////////////////////////////////////////////////////////////////////////////
  17. // CQueryDefSet implementation
  18.  
  19. IMPLEMENT_DYNAMIC(CQueryDefSet, CDaoRecordset)
  20.  
  21. CQueryDefSet::CQueryDefSet(CDaoDatabase* pdb)
  22.     : CDaoRecordset(pdb)
  23. {
  24.     //{{AFX_FIELD_INIT(CQueryDefSet)
  25.     m_Title = _T("");
  26.     m_Year_Published = 0;
  27.     m_ISBN = _T("");
  28.     m_PubID = 0;
  29.     m_Description = _T("");
  30.     m_Notes = _T("");
  31.     m_Subject = _T("");
  32.     m_Comments = _T("");
  33.     m_nFields = 8;
  34.     //}}AFX_FIELD_INIT
  35.     m_nDefaultType = dbOpenDynaset;
  36. }
  37.  
  38. CString CQueryDefSet::GetDefaultDBName()
  39. {
  40.     struct _finddata_t c_file;
  41.     long hFile;
  42.     CString fname = "..\\..\\biblio.mdb";
  43.  
  44.     hFile = _findfirst(fname, &c_file);
  45.     if (-1 != hFile)
  46.         return _T(fname);
  47.  
  48.     fname = "..\\biblio.mdb";
  49.     hFile = _findfirst(fname, &c_file);
  50.     if (-1 != hFile)
  51.         return _T(fname);
  52.  
  53.     return _T("");
  54. }
  55.  
  56.  
  57. CString CQueryDefSet::GetDefaultSQL()
  58. {
  59.     return _T("[Titles]");
  60. }
  61.  
  62. void CQueryDefSet::DoFieldExchange(CDaoFieldExchange* pFX)
  63. {
  64.     //{{AFX_FIELD_MAP(CQueryDefSet)
  65.     pFX->SetFieldType(CDaoFieldExchange::outputColumn);
  66.     DFX_Text(pFX, _T("[Title]"), m_Title);
  67.     DFX_Short(pFX, _T("[Year Published]"), m_Year_Published);
  68.     DFX_Text(pFX, _T("[ISBN]"), m_ISBN);
  69.     DFX_Long(pFX, _T("[PubID]"), m_PubID);
  70.     DFX_Text(pFX, _T("[Description]"), m_Description);
  71.     DFX_Text(pFX, _T("[Notes]"), m_Notes);
  72.     DFX_Text(pFX, _T("[Subject]"), m_Subject);
  73.     DFX_Text(pFX, _T("[Comments]"), m_Comments);
  74.     //}}AFX_FIELD_MAP
  75. }
  76.  
  77. /////////////////////////////////////////////////////////////////////////////
  78. // CQueryDefSet diagnostics
  79.  
  80. #ifdef _DEBUG
  81. void CQueryDefSet::AssertValid() const
  82. {
  83.     CDaoRecordset::AssertValid();
  84. }
  85.  
  86. void CQueryDefSet::Dump(CDumpContext& dc) const
  87. {
  88.     CDaoRecordset::Dump(dc);
  89. }
  90. #endif //_DEBUG
  91.