SOL9 Sample: ADOXViewsApplet

SOL9 2.0 Samples

1 Screenshot


2 Source code

/*
 * ADOXViewsApplet.cpp 
 * Copyright (c) 2015 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


// SOL9
// 2009/06/03
// Assumes that environment of SQL Server 2008 and SQLClient1.0 

#include <sol/sql/ADOXApplet.h>
#include <sol/Locale.h>

namespace SOL {

class ADOXViewsApplet: public ADOXApplet {

public:
  /**
   * Constructor
   */
  ADOXViewsApplet(int argc, const TCHAR** argv)
    :ADOXApplet(argc, argv)
  {
  }

public:
  ~ADOXViewsApplet()
  {
  }

public:
  /**
   * ADOXViewsApplet main procedure
   */
  virtual void run()
  {
    String encoding = "";
    getXMLEncoding(encoding);

    _tprintf(_T("<?xml version=\"1.0\" encoding=\"%s\" ?>\n"), (const TCHAR*)encoding);
    _tprintf(_T("<!-- \n"));
    _tprintf(_T("1 Start\n"));
    
    try {
      ADOXCatalog& catalog = getCatalog();

      ADOConnectionProperties& props = getConnectionProperties();

      String initialCatalog = "";
      props.getInitialCatalog(initialCatalog);
      _tprintf(_T("2 OK, opened a catalog %s\n"), (const TCHAR*)initialCatalog);
        _tprintf(_T("3 Try to catalog.getViews()\n"));

      ADOXViews views;

      catalog.getViews(views);
      _tprintf(_T("4 OK catalog.getViews()\n"));

      long l = views.getCount();
      _tprintf(_T("Views Count=%ld\n"), l);
      _tprintf(_T("-->\n"));

      views.dump();
      
      _tprintf(_T("<!-- Initial Catalog=%s; Dumped views count=%ld -->\n"),
        (const TCHAR*)initialCatalog, l); 

    } catch (Exception& ex) {
      ex.dump();
    } catch (_com_error& ex) {
      COMError error(ex);
      error.dump();
    } catch (...) {
      _tprintf(_T("Exception: Unknown\n"));
    }
  }
};

}

// Console application starts here.
void _tmain(int argc, const TCHAR** argv)
{
  Locale locale;
  try {
    ADOXViewsApplet applet(argc, argv);

    applet.start();

  } catch(Exception& ex){
    ex.dump();
  } catch(...){
    _tprintf(_T("Exception:Unknown\n"));
  }
}


Last modified: 2 May 2016

Copyright (c) 2016 Antillia.com ALL RIGHTS RESERVED.