home *** CD-ROM | disk | FTP | other *** search
- // SlowOrdersDetail.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 "SODet.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CSlowOrdersDetail
- IMPLEMENT_DYNAMIC(CSlowOrdersDetail, CRecordset)
-
- CSlowOrdersDetail::CSlowOrdersDetail(CDatabase* pdb)
- : CRecordset(pdb)
- {
- //{{AFX_FIELD_INIT(CSlowOrdersDetail)
- m_UnitPrice = _T("");
- m_Quantity = 0;
- m_Discount = _T("");
- m_ProductName = _T("");
- m_nFields = 4;
- //}}AFX_FIELD_INIT
-
- m_strFilter = m_defFilter = _T("OD.ProductID = P.ProductID");
- m_strOrderID = _T("");
- }
-
-
- CString CSlowOrdersDetail::GetDefaultConnect()
- {
- return _T("");
- }
-
- CString CSlowOrdersDetail::GetDefaultSQL()
- {
- return
- _T("SELECT OD.UnitPrice, OD.Quantity, OD.Discount, P.ProductName FROM [Order Details] OD, Products P");
- }
-
- void CSlowOrdersDetail::DoFieldExchange(CFieldExchange* pFX)
- {
- //{{AFX_FIELD_MAP(CSlowOrdersDetail)
- pFX->SetFieldType(CFieldExchange::outputColumn);
- RFX_Text(pFX, _T("[UnitPrice]"), m_UnitPrice);
- RFX_Long(pFX, _T("[Quantity]"), m_Quantity);
- RFX_Text(pFX, _T("[Discount]"), m_Discount);
- RFX_Text(pFX, _T("[ProductName]"), m_ProductName);
- //}}AFX_FIELD_MAP
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CSlowOrdersDetail diagnostics
- #ifdef _DEBUG
- void CSlowOrdersDetail::AssertValid() const
- {
- CRecordset::AssertValid();
- }
-
- void CSlowOrdersDetail::Dump(CDumpContext& dc) const
- {
- CRecordset::Dump(dc);
- }
- #endif //_DEBUG
-
- /*
- When using MFC with SQL Server, you should almost always override the Open
- member function. By default, the MFC ODBC CRecordset asks for a scrollable,
- updatable STATIC cursor. STATIC cursors are not updatable on SQL Server.
- Therefore, statement preparation fails on the statement. The MFC CRecordset
- will ask for an updatable cursor twice, before downgrading cursor
- concurrency to read-only.
-
- The effect can be seen in this example by using class wizard to add the code
- below to both detail recordsets, and then running the performance test menu
- item.
-
- Server roundtrips will drop from 453 to 140. Bytes sent should drop by
- roughly 2/3, and bytes received should more closely match that for the "fast"
- method.
-
- Rule: Know what type of behavior you need from your recordset, and then
- use the Open member function to enforce that behavior.
-
- BOOL CSlowOrdersDetail::Open(UINT nOpenType, LPCTSTR lpszSql, DWORD dwOptions)
- {
- return CRecordset::Open(CRecordset::forwardOnly, lpszSql, dwOptions);
- } */
-