home *** CD-ROM | disk | FTP | other *** search
- // FastOrdersSet.cpp : implementation file
- //
- // This file is part of Microsoft SQL Server online documentation.
- // Copyright (C) 1992-1997 Microsoft Corporation. All rights reserved.
- //
- // This source code is an intended supplement to the Microsoft SQL
- // Server online references and related electronic documentation.
- #include "stdafx.h"
- #include "MFCPerf.h"
- #include "FOSet.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CFastOrdersSet
- IMPLEMENT_DYNAMIC(CFastOrdersSet, CRecordset)
-
- CFastOrdersSet::CFastOrdersSet(CDatabase* pdb)
- : CRecordset(pdb)
- {
- //{{AFX_FIELD_INIT(CFastOrdersSet)
- //}}AFX_FIELD_INIT
- m_nFields = 4;
-
- // Changing default type ensures that blocking hstmt is used without
- // the ODBC cursor library.
- m_nDefaultType = CRecordset::readOnly;
-
- // Using bound parameters in place of MFC filter string modification.
- m_nParams = 1;
- }
-
- CString CFastOrdersSet::GetDefaultConnect()
- {
- // We don't allow the record set to connect on it's own. Dynamic
- // creation from the view passes the document's database to
- // the record set.
- return _T("");
- }
-
- CString CFastOrdersSet::GetDefaultSQL()
- {
- // ODBC canonical form of stored procedure execution.
- return _T("{call CustOrdersOrders(?)}");
- }
-
- void CFastOrdersSet::DoFieldExchange(CFieldExchange* pFX)
- {
- // Create our own field exchange mechanism. We must do this for two
- // reasons. First, MFC's class wizard cannot currently determine the data
- // types of procedure columns. Second, we must create our own parameter
- // data exchange lines to take advantage of a bound ODBC input parameter.
-
- //{{AFX_FIELD_MAP(CFastOrdersSet)
- pFX->SetFieldType(CFieldExchange::outputColumn);
- //}}AFX_FIELD_MAP
-
- RFX_Long(pFX, _T("OrderID"), m_nOrderID);
- RFX_Date(pFX, _T("OrderDate"), m_timeOrder);
- RFX_Date(pFX, _T("RequiredDate"), m_timeRequired);
- RFX_Date(pFX, _T("ShippedDate"), m_timeShipped);
-
- pFX->SetFieldType(CFieldExchange::param);
- RFX_Text(pFX, _T("@CustID"), m_strCustID);
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CFastOrdersSet diagnostics
- #ifdef _DEBUG
- void CFastOrdersSet::AssertValid() const
- {
- CRecordset::AssertValid();
- }
-
- void CFastOrdersSet::Dump(CDumpContext& dc) const
- {
- CRecordset::Dump(dc);
- }
- #endif //_DEBUG
-
- BOOL CFastOrdersSet::Open(UINT nOpenType, LPCTSTR lpszSql, DWORD dwOptions)
- {
- // Override the default behavior of the Open member function. We want to
- // ensure that the record set executes on the SQL Server default
- // (blocking) statement type.
- nOpenType = CRecordset::forwardOnly;
- dwOptions = CRecordset::readOnly;
-
- return CRecordset::Open(nOpenType, GetDefaultSQL(), dwOptions);
- }
-