home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 32 / IOPROG_32.ISO / SOFT / SqlEval7 / devtools / samples / ODBC / mfcperf / sodet.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-11-02  |  3.0 KB  |  97 lines

  1. // SlowOrdersDetail.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 "SODet.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. // CSlowOrdersDetail
  20. IMPLEMENT_DYNAMIC(CSlowOrdersDetail, CRecordset)
  21.  
  22. CSlowOrdersDetail::CSlowOrdersDetail(CDatabase* pdb)
  23.     : CRecordset(pdb)
  24.     {
  25.     //{{AFX_FIELD_INIT(CSlowOrdersDetail)
  26.     m_UnitPrice = _T("");
  27.     m_Quantity = 0;
  28.     m_Discount = _T("");
  29.     m_ProductName = _T("");
  30.     m_nFields = 4;
  31.     //}}AFX_FIELD_INIT
  32.  
  33.     m_strFilter = m_defFilter = _T("OD.ProductID = P.ProductID");
  34.     m_strOrderID = _T("");
  35.     }
  36.  
  37.  
  38. CString CSlowOrdersDetail::GetDefaultConnect()
  39.     {
  40.     return _T("");
  41.     }
  42.  
  43. CString CSlowOrdersDetail::GetDefaultSQL()
  44.     {
  45.     return 
  46.         _T("SELECT OD.UnitPrice, OD.Quantity, OD.Discount, P.ProductName FROM [Order Details] OD, Products P");
  47.     }
  48.  
  49. void CSlowOrdersDetail::DoFieldExchange(CFieldExchange* pFX)
  50.     {
  51.     //{{AFX_FIELD_MAP(CSlowOrdersDetail)
  52.     pFX->SetFieldType(CFieldExchange::outputColumn);
  53.     RFX_Text(pFX, _T("[UnitPrice]"), m_UnitPrice);
  54.     RFX_Long(pFX, _T("[Quantity]"), m_Quantity);
  55.     RFX_Text(pFX, _T("[Discount]"), m_Discount);
  56.     RFX_Text(pFX, _T("[ProductName]"), m_ProductName);
  57.     //}}AFX_FIELD_MAP
  58.     }
  59.  
  60. /////////////////////////////////////////////////////////////////////////////
  61. // CSlowOrdersDetail diagnostics
  62. #ifdef _DEBUG
  63. void CSlowOrdersDetail::AssertValid() const
  64.     {
  65.     CRecordset::AssertValid();
  66.     }
  67.  
  68. void CSlowOrdersDetail::Dump(CDumpContext& dc) const
  69.     {
  70.     CRecordset::Dump(dc);
  71.     }
  72. #endif //_DEBUG
  73.  
  74. /*
  75. When using MFC with SQL Server, you should almost always override the Open
  76.  member function. By default, the MFC ODBC CRecordset asks for a scrollable,
  77.  updatable STATIC cursor. STATIC cursors are not updatable on SQL Server.
  78.  Therefore, statement preparation fails on the statement. The MFC CRecordset
  79.  will ask for an updatable cursor twice, before downgrading cursor
  80.  concurrency to read-only.
  81.  
  82. The effect can be seen in this example by using class wizard to add the code
  83.  below to both detail recordsets, and then running the performance test menu
  84.  item.
  85.  
  86. Server roundtrips will drop from 453 to 140. Bytes sent should drop by
  87.  roughly 2/3, and bytes received should more closely match that for the "fast"
  88.  method.
  89.  
  90. Rule: Know what type of behavior you need from your recordset, and then
  91.  use the Open member function to enforce that behavior.
  92.  
  93. BOOL CSlowOrdersDetail::Open(UINT nOpenType, LPCTSTR lpszSql, DWORD dwOptions) 
  94.     {
  95.     return CRecordset::Open(CRecordset::forwardOnly, lpszSql, dwOptions);
  96.     } */
  97.