home *** CD-ROM | disk | FTP | other *** search
- // SlowOrdersSet.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 "SOSet.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- /////////////////////////////////////////////////////////////////////////////
- // CSlowOrdersSet
- IMPLEMENT_DYNAMIC(CSlowOrdersSet, CRecordset)
-
- CSlowOrdersSet::CSlowOrdersSet(CDatabase* pdb)
- : CRecordset(pdb)
- {
- //{{AFX_FIELD_INIT(CSlowOrdersSet)
- m_OrderID = 0;
- m_nFields = 4;
- //}}AFX_FIELD_INIT
- }
-
- CString CSlowOrdersSet::GetDefaultConnect()
- {
- return _T("");
- }
-
- CString CSlowOrdersSet::GetDefaultSQL()
- {
- return _T("[dbo].[Orders]");
-
- // Replacing the default SQL string with one of your own creation can often result
- // in reducing the number of bytes sent to the server, for example:
- // return _T("SELECT OrderID, OrderDate, RequiredDate, ShippedDate FROM Orders");
- }
-
- void CSlowOrdersSet::DoFieldExchange(CFieldExchange* pFX)
- {
- //{{AFX_FIELD_MAP(CSlowOrdersSet)
- pFX->SetFieldType(CFieldExchange::outputColumn);
- RFX_Long(pFX, _T("[OrderID]"), m_OrderID);
- RFX_Date(pFX, _T("[OrderDate]"), m_OrderDate);
- RFX_Date(pFX, _T("[RequiredDate]"), m_RequiredDate);
- RFX_Date(pFX, _T("[ShippedDate]"), m_ShippedDate);
- //}}AFX_FIELD_MAP
- }
-
- /////////////////////////////////////////////////////////////////////////////
- // CSlowOrdersSet diagnostics
- #ifdef _DEBUG
- void CSlowOrdersSet::AssertValid() const
- {
- CRecordset::AssertValid();
- }
-
- void CSlowOrdersSet::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 CSlowOrdersSet::Open(UINT nOpenType, LPCTSTR lpszSql, DWORD dwOptions)
- {
- return CRecordset::Open(CRecordset::forwardOnly, lpszSql, dwOptions);
- }
- */
-