home *** CD-ROM | disk | FTP | other *** search
/ One Click 21 / ONCK021.iso / desenvolvimento / dbtk / dbtkxml.exe / DATA.Z / DbSample.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-29  |  1.7 KB  |  74 lines

  1. // DbSample.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "DbXmlTools.h"
  6.  
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12.  
  13. //====== SHOW MESSAGES ==========================================
  14. void ShowMsg(CStringArray &strResult)
  15. {
  16.     int nMax = strResult.GetSize();
  17.     for (int iPos=0; iPos < nMax; iPos++)
  18.     {
  19.         if (nMax > 1) printf("%3d: %s\n",iPos+1,strResult.GetAt(iPos));
  20.         else          printf("%s\n",strResult.GetAt(iPos));
  21.     }
  22. }            
  23.  
  24. /////////////////////////////////////////////////////////////////////////////
  25. // The one and only application object
  26.  
  27. CWinApp theApp;
  28.  
  29. using namespace std;
  30.  
  31. int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
  32. {
  33.     int nRetCode = 0;
  34.  
  35.     // initialize MFC and print and error on failure
  36.     if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
  37.     {
  38.         // TODO: change error code to suit your needs
  39.         cerr << _T("Fatal Error: MFC initialization failed") << endl;
  40.         return(1);
  41.     }
  42.  
  43.     //====== INITIALIZE DBXMLTOOLS INTERFACE ==========
  44.     CDbXmlTools *pDbTkXml = new CDbXmlTools;
  45.  
  46.     //====== RUN SAMPLE COMMANDS ======================
  47.     CStringArray strResult;
  48.     CString strCmd;
  49.     int ret_;
  50.     do {
  51.         strCmd.Format("opendb sample.mdb");
  52.         ret_ = pDbTkXml->ExecCmd(strCmd,&strResult);
  53.         ShowMsg(strResult);
  54.         if (ret_ < 0)
  55.             break;
  56.     
  57.         strCmd.Format("table Employees");
  58.         ret_ = pDbTkXml->ExecCmd(strCmd,&strResult);
  59.         ShowMsg(strResult);
  60.         if (ret_ < 0)
  61.             break;
  62.  
  63.         strCmd.Format("XMLExport Emp.XML");
  64.         ret_ = pDbTkXml->ExecCmd(strCmd,&strResult);
  65.         ShowMsg(strResult);
  66.         } while (FALSE);
  67.     delete pDbTkXml;
  68.  
  69.     return nRetCode;
  70. }
  71.  
  72.  
  73.  
  74.