home *** CD-ROM | disk | FTP | other *** search
- // FastOrdersDetail.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 "FODet.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CFastOrdersDetail
- IMPLEMENT_DYNAMIC(CFastOrdersDetail, CRecordset)
-
- CFastOrdersDetail::CFastOrdersDetail(CDatabase* pdb)
- : CRecordset(pdb)
- {
- //{{AFX_FIELD_INIT(CFastOrdersDetail)
- //}}AFX_FIELD_INIT
- m_nFields = 5;
-
- // Changing default type ensures that default 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 CFastOrdersDetail::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 CFastOrdersDetail::GetDefaultSQL()
- {
- // ODBC canonical form of stored procedure execution.
- return _T("{call CustOrdersDetail(?)}");
- }
-
- void CFastOrdersDetail::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(CFastOrdersDetail)
- pFX->SetFieldType(CFieldExchange::outputColumn);
- //}}AFX_FIELD_MAP
- RFX_Text(pFX, _T("ProductName"), m_strProductName);
- RFX_Text(pFX, _T("UnitPrice"), m_strUnitPrice);
- RFX_Int(pFX, _T("Quantity"), m_nQuantity);
- RFX_Single(pFX, _T("Discount"), m_nDiscount);
- RFX_Text(pFX, _T("ExtendPrice"), m_strExtendPrice);
-
- pFX->SetFieldType(CFieldExchange::param);
- RFX_Long(pFX, _T("@OrderID"), m_nOrderID);
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CFastOrdersDetail diagnostics
- #ifdef _DEBUG
- void CFastOrdersDetail::AssertValid() const
- {
- CRecordset::AssertValid();
- }
-
- void CFastOrdersDetail::Dump(CDumpContext& dc) const
- {
- CRecordset::Dump(dc);
- }
- #endif //_DEBUG
-
- BOOL CFastOrdersDetail::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);
- }
-