home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 32 / IOPROG_32.ISO / SOFT / SqlEval7 / devtools / samples / ODBC / mfcperf / mfcpcust.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-20  |  2.4 KB  |  95 lines

  1. // MFCPCust.cpp : implementation of the CMFCPCust class
  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 "MFCPCust.h"
  11. #include "LoginDlg.h"
  12.  
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18.  
  19. /////////////////////////////////////////////////////////////////////////////
  20. // CMFCPCust implementation
  21. IMPLEMENT_DYNAMIC(CMFCPCust, CRecordset)
  22.  
  23. CMFCPCust::CMFCPCust(CDatabase* pdb)
  24.     : CRecordset(pdb)
  25.     {
  26.     //{{AFX_FIELD_INIT(CMFCPCust)
  27.     m_CustomerID = _T("");
  28.     m_CompanyName = _T("");
  29.     m_Country = _T("");
  30.     m_nFields = 3;
  31.     //}}AFX_FIELD_INIT
  32.     m_nDefaultType = dynaset;
  33.  
  34.     m_strConnect = _T("");
  35.     }
  36.  
  37. CString CMFCPCust::GetDefaultConnect()
  38.     {
  39.     if (m_strConnect.GetLength() == 0)
  40.         {
  41.         CLoginDlg   dlg;
  42.         if (dlg.DoModal() == IDOK)
  43.             {
  44.             m_strConnect = _T("ODBC;DSN=");
  45.             m_strConnect += dlg.m_strDSN;
  46.             if (dlg.m_bIntegrated == TRUE)
  47.                 {
  48.                 m_strConnect += _T(";Trusted_Connection=yes");
  49.                 }
  50.             else
  51.                 {
  52.                 if (dlg.m_strUID.GetLength())
  53.                     {
  54.                     m_strConnect += _T(";UID=");
  55.                     m_strConnect += dlg.m_strUID;
  56.  
  57.                     m_strConnect += _T(";PWD=");
  58.                     m_strConnect += dlg.m_strPWD;
  59.                     }
  60.                 }
  61.             }
  62.         }
  63.  
  64.     return (m_strConnect);
  65.     }
  66.  
  67. CString CMFCPCust::GetDefaultSQL()
  68.     {
  69.     return _T("[dbo].[Customers]");
  70.     }
  71.  
  72. void CMFCPCust::DoFieldExchange(CFieldExchange* pFX)
  73.     {
  74.     //{{AFX_FIELD_MAP(CMFCPCust)
  75.     pFX->SetFieldType(CFieldExchange::outputColumn);
  76.     RFX_Text(pFX, _T("[CustomerID]"), m_CustomerID);
  77.     RFX_Text(pFX, _T("[CompanyName]"), m_CompanyName);
  78.     RFX_Text(pFX, _T("[Country]"), m_Country);
  79.     //}}AFX_FIELD_MAP
  80.     }
  81.  
  82. /////////////////////////////////////////////////////////////////////////////
  83. // CMFCPCust diagnostics
  84. #ifdef _DEBUG
  85. void CMFCPCust::AssertValid() const
  86.     {
  87.     CRecordset::AssertValid();
  88.     }
  89.  
  90. void CMFCPCust::Dump(CDumpContext& dc) const
  91.     {
  92.     CRecordset::Dump(dc);
  93.     }
  94. #endif //_DEBUG
  95.