SOL9 Sample: OpenSchemaApplet

SOL9 2.0 Samples

1 Screenshot


2 Source code

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


// SOL9
// 2009/05/20

// Assumes that environment of SQL Server 2008 and SQLClient1.0 
// Please create a database 'Sample' for this example.
// 

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

namespace SOL {

class OpenSchemaApplet: public ADOApplet {

public:
  /**
   * Constructor
   */
  OpenSchemaApplet(int argc, const TCHAR** argv)
    :ADOApplet(argc, argv)
  {
  }

public:
  ~OpenSchemaApplet()
  {
  }

public:
  /**
   * OpenSchemaApplet main procedure
   */
  virtual void run()
  {
    printf("1 Start\n");
    ADOConnection connection = getConnection();

    ADORecordset schemaset;  
    printf("2 Try to connection.openSchema(adSchemaTables)\n");

    connection.openSchema(ADODB::adSchemaTables, schemaset);
    printf("3 OK, connection.openSchema()\n");
    
    while(!schemaset.getadoEOF()){
      ADOFields fields;
      schemaset.getFields(fields);
      printf("\n4 Found a Schema: ");
      ADOField field;
      char* it[] = {"TABLE_NAME", "TABLE_TYPE"};
      for (int i = 0; i<sizeof(it)/sizeof(it[0]); i++) {
        fields.getItem(it[i], field);
        _bstr_t value = field.getValue();
        printf("%s=\"%S\" ", it[i], (const wchar_t*)value);
      }
      schemaset.moveNext();        
    }
  }
};

}


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

    OpenSchemaApplet openSchemaApplet(argc, argv);

    openSchemaApplet.start();

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

Last modified: 2 May 2016

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