home *** CD-ROM | disk | FTP | other *** search
/ Supercompiler 1997 / SUPERCOMPILER97.iso / MS_DAO.SDK / DISK4 / DAOSDK.1 / daorddlg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-09-14  |  15.8 KB  |  630 lines

  1. // DAOReadDlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "DAORead.h"
  6. #include "DAORdDlg.h"
  7. #include <dbdaoerr.h>
  8.  
  9. #ifdef _DEBUG
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CAboutDlg dialog used for App About
  16.  
  17. class CAboutDlg : public CDialog
  18. {
  19. public:
  20.     CAboutDlg();
  21.  
  22. // Dialog Data
  23.     //{{AFX_DATA(CAboutDlg)
  24.     enum { IDD = IDD_ABOUTBOX };
  25.     //}}AFX_DATA
  26.  
  27. // Implementation
  28. protected:
  29.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  30.     //{{AFX_MSG(CAboutDlg)
  31.     //}}AFX_MSG
  32.     DECLARE_MESSAGE_MAP()
  33. };
  34.  
  35. CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
  36. {
  37.     //{{AFX_DATA_INIT(CAboutDlg)
  38.     //}}AFX_DATA_INIT
  39. }
  40.  
  41. void CAboutDlg::DoDataExchange(CDataExchange* pDX)
  42. {
  43.     CDialog::DoDataExchange(pDX);
  44.     //{{AFX_DATA_MAP(CAboutDlg)
  45.     //}}AFX_DATA_MAP
  46. }
  47.  
  48. BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
  49.     //{{AFX_MSG_MAP(CAboutDlg)
  50.         // No message handlers
  51.     //}}AFX_MSG_MAP
  52. END_MESSAGE_MAP()
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. // CDAOReadDlg dialog
  56.  
  57. CDAOReadDlg::CDAOReadDlg(CWnd* pParent /*=NULL*/)
  58.     : CDialog(CDAOReadDlg::IDD, pParent)
  59. {
  60.     //{{AFX_DATA_INIT(CDAOReadDlg)
  61.     m_lCacheSize = 100;
  62.     m_strTableQuery = _T("");
  63.     m_lNumRows = 10;
  64.     m_bOpenRecordset = TRUE;
  65.     m_bTable = TRUE;
  66.     m_bDynaSet = TRUE;
  67.     m_bDynaSetCache = TRUE;
  68.     m_bSnapshot = TRUE;
  69.     m_bGetRows = TRUE;
  70.     m_strDatabase = _T("");
  71.     m_strConnect = _T("");
  72.     m_bExclusive = FALSE;
  73.     m_bReadOnly = FALSE;
  74.     //}}AFX_DATA_INIT
  75.     // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  76.     m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  77. }
  78.  
  79. void CDAOReadDlg::DoDataExchange(CDataExchange* pDX)
  80. {
  81.     CDialog::DoDataExchange(pDX);
  82.     //{{AFX_DATA_MAP(CDAOReadDlg)
  83.     DDX_Text(pDX, IDC_CACHESIZE, m_lCacheSize);
  84.     DDV_MinMaxLong(pDX, m_lCacheSize, 0, 1200);
  85.     DDX_Text(pDX, IDC_TABLEQUERYEDIT, m_strTableQuery);
  86.     DDX_Text(pDX, IDC_NUMROWS, m_lNumRows);
  87.     DDV_MinMaxLong(pDX, m_lNumRows, 1, 32000);
  88.     DDX_Check(pDX, IDC_OPENRECORDSET, m_bOpenRecordset);
  89.     DDX_Check(pDX, IDC_TABLE, m_bTable);
  90.     DDX_Check(pDX, IDC_DYNASET, m_bDynaSet);
  91.     DDX_Check(pDX, IDC_DYNASETCACHE, m_bDynaSetCache);
  92.     DDX_Check(pDX, IDC_SNAPSHOT, m_bSnapshot);
  93.     DDX_Check(pDX, IDC_GETROWS, m_bGetRows);
  94.     DDX_Text(pDX, IDC_DATABASENAME, m_strDatabase);
  95.     DDV_MaxChars(pDX, m_strDatabase, 256);
  96.     DDX_Text(pDX, IDC_CONNECT, m_strConnect);
  97.     DDV_MaxChars(pDX, m_strConnect, 256);
  98.     DDX_Check(pDX, IDC_EXCLUSIVE, m_bExclusive);
  99.     DDX_Check(pDX, IDC_READONLY, m_bReadOnly);
  100.     //}}AFX_DATA_MAP
  101.  
  102.     //Do the manual checks
  103.  
  104.     //Check the database name parameter
  105.     if(pDX->m_bSaveAndValidate)
  106.         {
  107.         pDX->PrepareEditCtrl(IDC_DATABASENAME);
  108.         if (m_strDatabase.IsEmpty()) 
  109.             {
  110.             MessageBox(_T("Missing Jet database name."), _T("DAO Test App Error"), MB_ICONEXCLAMATION );
  111.             pDX->Fail();
  112.             }
  113.         }
  114.  
  115.  
  116.     //Check the Table/Query parameter
  117.     if(pDX->m_bSaveAndValidate)
  118.         {
  119.         pDX->PrepareEditCtrl(IDC_TABLEQUERYEDIT);
  120.         if (m_strTableQuery.IsEmpty()) 
  121.             {
  122.             MessageBox(_T("Missing table,query or SQL."), _T("DAO Test App Error"), MB_ICONEXCLAMATION );
  123.             pDX->Fail();
  124.             }
  125.         }
  126. }
  127.  
  128. BEGIN_MESSAGE_MAP(CDAOReadDlg, CDialog)
  129.     //{{AFX_MSG_MAP(CDAOReadDlg)
  130.     ON_WM_SYSCOMMAND()
  131.     ON_WM_PAINT()
  132.     ON_WM_QUERYDRAGICON()
  133.     ON_BN_CLICKED(IDC_DATABASE, OnDatabase)
  134.     ON_BN_CLICKED(ID_EXECUTE, OnExecute)
  135.     //}}AFX_MSG_MAP
  136. END_MESSAGE_MAP()
  137.  
  138. /////////////////////////////////////////////////////////////////////////////
  139. // CDAOReadDlg message handlers
  140.  
  141. BOOL CDAOReadDlg::OnInitDialog()
  142. {
  143.     CDialog::OnInitDialog();
  144.  
  145.     // Add "About..." menu item to system menu.
  146.  
  147.     // IDM_ABOUTBOX must be in the system command range.
  148.     ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
  149.     ASSERT(IDM_ABOUTBOX < 0xF000);
  150.  
  151.     CMenu* pSysMenu = GetSystemMenu(FALSE);
  152.     CString strAboutMenu;
  153.     strAboutMenu.LoadString(IDS_ABOUTBOX);
  154.     if (!strAboutMenu.IsEmpty())
  155.     {
  156.         pSysMenu->AppendMenu(MF_SEPARATOR);
  157.         pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
  158.     }
  159.     
  160.  
  161.     //Set default selections
  162.     SetDlgItemText(IDC_CACHESIZE, _T("100"));
  163.     SetDlgItemText(IDC_EDIT9, _T("1"));
  164.     
  165.     return TRUE;  // return TRUE  unless you set the focus to a control
  166. }
  167.  
  168. void CDAOReadDlg::OnSysCommand(UINT nID, LPARAM lParam)
  169. {
  170.     if ((nID & 0xFFF0) == IDM_ABOUTBOX)
  171.     {
  172.         CAboutDlg dlgAbout;
  173.         dlgAbout.DoModal();
  174.     }
  175.     else
  176.     {
  177.         CDialog::OnSysCommand(nID, lParam);
  178.     }
  179. }
  180.  
  181. // If you add a minimize button to your dialog, you will need the code below
  182. //  to draw the icon.  For MFC applications using the document/view model,
  183. //  this is automatically done for you by the framework.
  184.  
  185. void CDAOReadDlg::OnPaint() 
  186. {
  187.     if (IsIconic())
  188.     {
  189.         CPaintDC dc(this); // device context for painting
  190.  
  191.         SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  192.  
  193.         // Center icon in client rectangle
  194.         int cxIcon = GetSystemMetrics(SM_CXICON);
  195.         int cyIcon = GetSystemMetrics(SM_CYICON);
  196.         CRect rect;
  197.         GetClientRect(&rect);
  198.         int x = (rect.Width() - cxIcon + 1) / 2;
  199.         int y = (rect.Height() - cyIcon + 1) / 2;
  200.  
  201.         // Draw the icon
  202.         dc.DrawIcon(x, y, m_hIcon);
  203.     }
  204.     else
  205.     {
  206.         CDialog::OnPaint();
  207.     }
  208. }
  209.  
  210. // The system calls this to obtain the cursor to display while the user drags
  211. //  the minimized window.
  212. HCURSOR CDAOReadDlg::OnQueryDragIcon()
  213. {
  214.     return (HCURSOR) m_hIcon;
  215. }
  216.  
  217. void CDAOReadDlg::OnDatabase() 
  218. {
  219.     CFileDialog*    pcBrowse;    //Need a file open dialog
  220.  
  221.     pcBrowse = (CFileDialog*)new CFileDialog(TRUE,_T("mdb"),NULL,NULL,_T("Jet Database Files | *.mdb ||"), NULL)    ;
  222.  
  223.     pcBrowse->DoModal();
  224.  
  225.     (GetDlgItem(IDC_DATABASENAME))->SetWindowText(pcBrowse->GetPathName());
  226.  
  227.     delete pcBrowse;
  228. }
  229.  
  230.  
  231.  
  232. //When the Execute button is pressed, run through the selected methods and perform each
  233. //reporting an approximate execution time and listing the first field returned (only if
  234. //it's a string or numeric)
  235.  
  236. void CDAOReadDlg::OnExecute() 
  237. {
  238.     DWORD            dwStart, dwEnd;
  239.     DWORD            dwDuration;
  240.     LONG            lIndex;
  241.     COleVariant        dbVar;
  242.     CListBox        *pList = ((CListBox *)(GetDlgItem(IDC_ROWSLIST)));
  243.  
  244.     //Update the parameters
  245.     if (!UpdateData(TRUE))
  246.         {
  247.         return;
  248.         }
  249.  
  250.     // This could take a while, 
  251.     CWaitCursor wait;
  252.  
  253.     //Clear the list
  254.     pList->ResetContent();
  255.  
  256.  
  257.     // Following is a series of database table retrieves using variations
  258.     // on the Recordset object. This isn't a great programming structure,
  259.     // but it shows each method clearly.
  260.     
  261.     //Execute each the requested read methods, recording a time for each
  262.     try
  263.         {
  264.         //Open the database
  265.         (GetDlgItem(IDC_DATABASENAME))->GetWindowText(m_strDatabase);
  266.     
  267.         m_dbDatabase = m_dbEngine.OpenDatabase(    m_strDatabase,
  268.                                                 m_bExclusive,
  269.                                                 m_bReadOnly,
  270.                                                 m_strConnect);
  271.  
  272.         //Run through the selected methods, recording each time
  273.         
  274.         if(m_bOpenRecordset)
  275.             {
  276.             //Recordset as a Table
  277.             if(m_bTable)
  278.                 {
  279.                 CdbRecordset RSetTable; 
  280.                 pList->AddString(_T("Recordset/Table"));
  281.                 pList->AddString(_T("=========================="));
  282.  
  283.                 dwStart = timeGetTime();
  284.         
  285.                 //Open recordset on a table
  286.                 try
  287.                     {
  288.                     RSetTable = m_dbDatabase.OpenRecordset(m_strTableQuery, dbOpenTable);
  289.                     }
  290.                 //If the object was not found, assume it was something not openable
  291.                 //as a "table"
  292.                 catch(CdbException dbError)
  293.                     {
  294.                     if(dbError.m_hr != E_DAO_ObjectNotFound)
  295.                         throw dbError;
  296.                     }
  297.                 //Check that recordset was created
  298.                 if (RSetTable.Exists())
  299.                     {
  300.                     //Get requested number of records
  301.                     for (lIndex = 0L; !RSetTable.GetEOF() && lIndex < m_lNumRows; lIndex++)
  302.                         {
  303.                         //Get the first returned column
  304.                         dbVar = RSetTable.GetField(0L);
  305.                         AddFieldToList(lIndex, &dbVar);
  306.             
  307.                         RSetTable.MoveNext();
  308.                         }
  309.     
  310.                     //Report the estimated execute time (in milliseconds)
  311.                     dwEnd = timeGetTime();
  312.                     dwDuration = dwEnd - dwStart;
  313.                     DisplayQueryTime(IDC_TABLETIME, IDC_UNITTABLE, dwDuration);
  314.                     }
  315.                 else
  316.                     {
  317.                     (GetDlgItem(IDC_TABLETIME))->SetWindowText(_T("ERROR"));
  318.                     }
  319.                 }
  320.  
  321.             //Recordset as a Dynaset
  322.             if(m_bDynaSet)
  323.                 {
  324.                 CdbRecordset RSetDyna; 
  325.                 pList->AddString(_T("Recordset/Dynaset"));
  326.                 pList->AddString(_T("=========================="));
  327.  
  328.                 dwStart = timeGetTime();
  329.         
  330.                 //Open recordset on as a Dynaset
  331.                 RSetDyna =  m_dbDatabase.OpenRecordset(m_strTableQuery, dbOpenDynaset);
  332.  
  333.                 //Check that recordset was created
  334.                 if (RSetDyna.Exists())
  335.                     {
  336.                     //Get requested number of records
  337.                     for (lIndex = 0L; !RSetDyna.GetEOF() && lIndex < m_lNumRows; lIndex++)
  338.                         {
  339.                         //Get the first returned column
  340.                         dbVar = RSetDyna.GetField(0L);
  341.                         AddFieldToList(lIndex, &dbVar);
  342.                         RSetDyna.MoveNext();
  343.                         }
  344.     
  345.                     //Report the estimated execute time (in milliseconds)
  346.                     dwEnd = timeGetTime();
  347.                     dwDuration = dwEnd - dwStart;
  348.                     DisplayQueryTime(IDC_DYNASETTIME, IDC_UNITDYNA, dwDuration);
  349.                     }
  350.                 else
  351.                     {
  352.                     (GetDlgItem(IDC_DYNASETTIME))->SetWindowText(_T("ERROR"));
  353.                     }
  354.                 }
  355.  
  356.             //Recordset as a Dynaset with cacheing
  357.             if(m_bDynaSet && m_bDynaSetCache)
  358.                 {
  359.                 CdbRecordset    RSetDynaCache; 
  360.                 CdbBookmark        DynaSetBookmark;
  361.  
  362.                 pList->AddString(_T("Recordset/Dynaset cached"));
  363.                 pList->AddString(_T("=========================="));
  364.  
  365.                 dwStart = timeGetTime();
  366.         
  367.                 //Open recordset on as a Dynaset
  368.                 RSetDynaCache =  m_dbDatabase.OpenRecordset(m_strTableQuery, dbOpenDynaset);
  369.                 
  370.                 //Check that recordset was created
  371.                 if (RSetDynaCache.Exists())
  372.                     {
  373.                     //Set the cache size to value supplied by user.
  374.                     RSetDynaCache.SetCacheSize(m_lCacheSize);
  375.                     RSetDynaCache.FillCache(); 
  376.         
  377.                     //Get requested number of records
  378.                     for (lIndex = 0L; !RSetDynaCache.GetEOF() && lIndex < m_lNumRows; lIndex++)
  379.                         {
  380.                         //Get the first returned column
  381.                         dbVar = RSetDynaCache.GetField(0L);
  382.                         AddFieldToList(lIndex, &dbVar);
  383.                         RSetDynaCache.MoveNext();
  384.  
  385.                         //Watch for cache run-out
  386.                         if (lIndex % m_lCacheSize)
  387.                             {    
  388.                             DynaSetBookmark = RSetDynaCache.GetBookmark();
  389.                             RSetDynaCache.SetCacheStart(DynaSetBookmark);
  390.                             RSetDynaCache.FillCache(); 
  391.                             }
  392.                         }
  393.     
  394.                     //Report the estimated execute time (in milliseconds)
  395.                     dwEnd = timeGetTime();
  396.                     dwDuration = dwEnd - dwStart;
  397.                     DisplayQueryTime(IDC_CACHETIME, IDC_UNITCACHE, dwDuration);
  398.                     }
  399.                 else
  400.                     {
  401.                     (GetDlgItem(IDC_CACHETIME))->SetWindowText(_T("ERROR"));
  402.                     }
  403.                 }            
  404.  
  405.             //Recordset as a Snapshot
  406.             if(m_bSnapshot)
  407.                 {
  408.                 // Bidirectional Snapshot
  409.                 CdbRecordset RSetSnap; 
  410.                 pList->AddString(_T("Recordset/Snapshot"));
  411.                 pList->AddString(_T("=========================="));
  412.  
  413.                 dwStart = timeGetTime();
  414.         
  415.                 //Open recordset on as a Snapshot
  416.                 RSetSnap =  m_dbDatabase.OpenRecordset(m_strTableQuery, dbOpenSnapshot);
  417.  
  418.                 //Check that recordset was created
  419.                 if (RSetSnap.Exists())
  420.                     {
  421.                     //Get requested number of records
  422.                     for (lIndex = 0L; !RSetSnap.GetEOF() && lIndex < m_lNumRows; lIndex++)
  423.                         {
  424.                         //Get the first returned column
  425.                         dbVar = RSetSnap.GetField(0L);
  426.                         AddFieldToList(lIndex, &dbVar);
  427.                         RSetSnap.MoveNext();
  428.                         }
  429.     
  430.                     //Report the estimated execute time (in milliseconds)
  431.                     dwEnd = timeGetTime();
  432.                     dwDuration = dwEnd - dwStart;
  433.                     DisplayQueryTime(IDC_SNAPSHOTTIME, IDC_UNITSNAP, dwDuration);
  434.                     }
  435.                 else
  436.                     {
  437.                     (GetDlgItem(IDC_SNAPSHOTTIME))->SetWindowText(_T("ERROR"));
  438.                     }
  439.  
  440.                 //Forward Only snapshot
  441.                 CdbRecordset RSetSnapForward; 
  442.                 pList->AddString(_T("Recordset/Snapshot forward only"));
  443.                 pList->AddString(_T("=========================="));
  444.  
  445.                 dwStart = timeGetTime();
  446.         
  447.                 //Open recordset on as a Forward only Snapshot
  448.                 RSetSnapForward =  m_dbDatabase.OpenRecordset(m_strTableQuery, dbOpenSnapshot, dbForwardOnly);
  449.  
  450.                 //Check that recordset was created
  451.                 if (RSetSnapForward.Exists())
  452.                     {
  453.                     //Get requested number of records
  454.                     for (lIndex = 0L; !RSetSnapForward.GetEOF() && lIndex < m_lNumRows; lIndex++)
  455.                         {
  456.                         //Get the first returned column
  457.                         dbVar = RSetSnapForward.GetField(0L);
  458.                         AddFieldToList(lIndex, &dbVar);
  459.                         RSetSnapForward.MoveNext();
  460.                         }
  461.     
  462.                     //Report the estimated execute time (in milliseconds)
  463.                     dwEnd = timeGetTime();
  464.                     dwDuration = dwEnd - dwStart;
  465.                     DisplayQueryTime(IDC_FORWARDTIME, IDC_UNITSNAPF, dwDuration);
  466.                     }
  467.                 else
  468.                     {
  469.                     (GetDlgItem(IDC_FORWARDTIME))->SetWindowText(_T("ERROR"));
  470.                     }
  471.  
  472.                 }
  473.  
  474.             //Getrows
  475.             if(m_bGetRows)
  476.                 {
  477.                 CdbRecordset    RSetGetRows; 
  478.                 COleVariant        cRows; // Returned rows (in SafeArray)
  479.                 LONG            lActual;
  480.                 LONG            lGetRowsIndex[2];
  481.  
  482.                 pList->AddString(_T("GetRows"));
  483.                 pList->AddString(_T("=========================="));
  484.  
  485.                 dwStart = timeGetTime();
  486.         
  487.                 //Open recordset on as a Forward only Snapshot
  488.                 RSetGetRows =  m_dbDatabase.OpenRecordset(m_strTableQuery, dbOpenSnapshot, dbForwardOnly);
  489.  
  490.                 //Check that recordset was created
  491.                 if (RSetGetRows.Exists())
  492.                     {
  493.                     cRows = RSetGetRows.GetRows(m_lNumRows); // get requested rows
  494.  
  495.                     //Find out how many records were actually retrieved
  496.                     SafeArrayGetUBound(cRows.parray, 1, &lActual);
  497.                     if(lActual > m_lNumRows)
  498.                         lActual = m_lNumRows;
  499.  
  500.                      lGetRowsIndex[0] = 0L;
  501.  
  502.                     for (lGetRowsIndex[1] = 0; lGetRowsIndex[1] < lActual; lGetRowsIndex[1]++)
  503.                         {
  504.             
  505.                         //Use OLE safe array function to access fields
  506.                         SafeArrayGetElement(cRows.parray, &lGetRowsIndex[0], &dbVar);
  507.                         AddFieldToList(lGetRowsIndex[1], &dbVar);
  508.                         }
  509.     
  510.                     //Report the estimated execute time (in milliseconds)
  511.                     dwEnd = timeGetTime();
  512.                     dwDuration = dwEnd - dwStart;
  513.                     DisplayQueryTime(IDC_GETROWSTIME, IDC_UNITGETROWS, dwDuration);
  514.                     }
  515.                 else
  516.                     {
  517.                     (GetDlgItem(IDC_GETROWSTIME))->SetWindowText(_T("ERROR"));
  518.                     }
  519.                 }                            
  520.             }
  521.  
  522.         //Disconnect the database
  523.         }
  524.  
  525.     catch (CdbException dbError)
  526.         {
  527.         CdbLastOLEError exError;
  528.         TCHAR szBuf[256];
  529.  
  530.         wsprintf(szBuf, _T("Error %d : %s\n"), DBERR(dbError.m_hr), 
  531.             (LPCTSTR) exError.GetDescription());
  532.         AfxMessageBox(szBuf);
  533.         }
  534.  
  535. }
  536.  
  537.  
  538. /////////////////////////////////////////////////////////////////////////////
  539. // Other functions
  540.  
  541. void CDAOReadDlg::DisplayQueryTime(int iControlID, int iUnitsID, DWORD dwDuration)
  542. {
  543.     CString strDisp;
  544.     CString strUnits(_T("ms"));
  545.     double    fDuration = dwDuration;
  546.     
  547.     //Did it go into minutes?
  548.     if(fDuration >= 60000.0)
  549.         {
  550.         fDuration = fDuration/60000.0;
  551.         strUnits = _T("M");
  552.         }
  553.     //Did it go to seconds?
  554.     else if(fDuration >= 1000.0)
  555.         {
  556.         fDuration = fDuration/1000.0;
  557.         strUnits = _T("S");
  558.         }
  559.  
  560.     strDisp.Format(_T("%.2f"), fDuration);
  561.  
  562.     (GetDlgItem(iUnitsID))->SetWindowText(strUnits);
  563.     (GetDlgItem(iControlID))->SetWindowText(strDisp);
  564.  
  565. }
  566.  
  567. void CDAOReadDlg::AddFieldToList(LONG lRecordNum, COleVariant *pdbVar)
  568. {
  569.     CString        strDisp;
  570.     CString        strScratch;
  571.     CListBox    *pList = ((CListBox *)(GetDlgItem(IDC_ROWSLIST)));
  572.  
  573.     //Add record number
  574.     strDisp.Format(_T("%d - "), lRecordNum);
  575.     
  576.     //NOTE: This only works for strings/numerics
  577.     
  578.     switch(pdbVar->vt)
  579.         {
  580.         case VT_BSTR:
  581.             {
  582.             strDisp += (LPCTSTR)pdbVar->bstrVal;
  583.             break;
  584.             }
  585.  
  586.         case VT_I4:
  587.             {
  588.             strScratch.Format(_T("%d"), pdbVar->lVal);
  589.             strDisp += strScratch;
  590.             break;
  591.             }
  592.  
  593.         case VT_UI1:
  594.             {
  595.             strScratch.Format(_T("%u"), pdbVar->bVal);
  596.             strDisp += strScratch;
  597.             break;
  598.             }
  599.  
  600.         case VT_I2:
  601.             {
  602.             strScratch.Format(_T("%d"), pdbVar->iVal);
  603.             strDisp += strScratch;
  604.             break;
  605.             }
  606.  
  607.         case VT_R4:
  608.             {
  609.             strScratch.Format(_T("%f"), pdbVar->fltVal);
  610.             strDisp += strScratch;
  611.             break;
  612.             }
  613.  
  614.         case VT_R8 :
  615.             {
  616.             strScratch.Format(_T("%f"), pdbVar->dblVal);
  617.             strDisp += strScratch;
  618.             break;
  619.             }
  620.  
  621.         default: //
  622.             {
  623.             strDisp += _T("Field type not supported by sample code");
  624.             }
  625.  
  626.         }
  627.     pList->AddString(strDisp);
  628.  
  629. }
  630.