home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 32 / IOPROG_32.ISO / SOFT / SqlEval7 / devtools / samples / ODBC / mfcperf / foset.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-20  |  2.9 KB  |  95 lines

  1. // FastOrdersSet.cpp : implementation file
  2. //
  3. // This file is part of Microsoft SQL Server online documentation.
  4. // Copyright (C) 1992-1997 Microsoft Corporation. All rights reserved.
  5. //
  6. // This source code is an intended supplement to the Microsoft SQL
  7. // Server online references and related electronic documentation.
  8. #include "stdafx.h"
  9. #include "MFCPerf.h"
  10. #include "FOSet.h"
  11.  
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17.  
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CFastOrdersSet
  20. IMPLEMENT_DYNAMIC(CFastOrdersSet, CRecordset)
  21.  
  22. CFastOrdersSet::CFastOrdersSet(CDatabase* pdb)
  23.     : CRecordset(pdb)
  24.     {
  25.     //{{AFX_FIELD_INIT(CFastOrdersSet)
  26.     //}}AFX_FIELD_INIT
  27.     m_nFields = 4;
  28.  
  29.     // Changing default type ensures that blocking hstmt is used without
  30.     //  the ODBC cursor library.
  31.     m_nDefaultType = CRecordset::readOnly;
  32.  
  33.     // Using bound parameters in place of MFC filter string modification.
  34.     m_nParams = 1;
  35.     }
  36.  
  37. CString CFastOrdersSet::GetDefaultConnect()
  38.     {
  39.     // We don't allow the record set to connect on it's own. Dynamic
  40.     //  creation from the view passes the document's database to
  41.     //  the record set.
  42.     return _T("");
  43.     }
  44.  
  45. CString CFastOrdersSet::GetDefaultSQL()
  46.     {
  47.     // ODBC canonical form of stored procedure execution.
  48.     return _T("{call CustOrdersOrders(?)}");
  49.     }
  50.  
  51. void CFastOrdersSet::DoFieldExchange(CFieldExchange* pFX)
  52.     {
  53.     // Create our own field exchange mechanism. We must do this for two
  54.     //  reasons. First, MFC's class wizard cannot currently determine the data
  55.     //  types of procedure columns. Second, we must create our own parameter
  56.     //  data exchange lines to take advantage of a bound ODBC input parameter.
  57.  
  58.     //{{AFX_FIELD_MAP(CFastOrdersSet)
  59.     pFX->SetFieldType(CFieldExchange::outputColumn);
  60.     //}}AFX_FIELD_MAP
  61.     
  62.     RFX_Long(pFX, _T("OrderID"), m_nOrderID);
  63.     RFX_Date(pFX, _T("OrderDate"), m_timeOrder);
  64.     RFX_Date(pFX, _T("RequiredDate"), m_timeRequired);
  65.     RFX_Date(pFX, _T("ShippedDate"), m_timeShipped);
  66.  
  67.     pFX->SetFieldType(CFieldExchange::param);
  68.     RFX_Text(pFX, _T("@CustID"), m_strCustID);
  69.     }
  70.  
  71. /////////////////////////////////////////////////////////////////////////////
  72. // CFastOrdersSet diagnostics
  73. #ifdef _DEBUG
  74. void CFastOrdersSet::AssertValid() const
  75.     {
  76.     CRecordset::AssertValid();
  77.     }
  78.  
  79. void CFastOrdersSet::Dump(CDumpContext& dc) const
  80.     {
  81.     CRecordset::Dump(dc);
  82.     }
  83. #endif //_DEBUG
  84.  
  85. BOOL CFastOrdersSet::Open(UINT nOpenType, LPCTSTR lpszSql, DWORD dwOptions) 
  86.     {
  87.     // Override the default behavior of the Open member function. We want to
  88.     //  ensure that the record set executes on the SQL Server default
  89.     //  (blocking) statement type.
  90.     nOpenType = CRecordset::forwardOnly;
  91.     dwOptions = CRecordset::readOnly;
  92.  
  93.     return CRecordset::Open(nOpenType, GetDefaultSQL(), dwOptions);
  94.     }
  95.