home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 32 / IOPROG_32.ISO / SOFT / SqlEval7 / MSOLAP / samples / Samples.exe / CppOlapDemo / OLAPDemo.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-30  |  24.5 KB  |  527 lines

  1. //-----------------------------------------------------------------------------
  2. // Microsoft OLE DB QLAPDEMO Sample
  3. // Copyright (C) 1995-1998 Microsoft Corporation
  4. //
  5. // File: OLAPDemo.cpp
  6. //
  7. // This file contains the main function for OlapDemo
  8. //
  9. //-----------------------------------------------------------------------------
  10.  
  11. #include <conio.h>
  12.  
  13. #include <stdio.h> 
  14. #include <stdlib.h> 
  15. #include <string.h> 
  16.  
  17. // Initilaizes OLEDB Guids / Constants
  18. // There should one and only one file in the project which #defines those
  19. #define DBINITCONSTANTS  1
  20. #define INITGUID         1
  21. #define OLEDBVER         0x0200
  22.  
  23. #include "OLAP.h" 
  24.  
  25. extern void    PrintPrompt( OLAPApp*  app );
  26.  
  27. BOOL    g_CtrlC = FALSE;
  28.  
  29. //////////////////////////////////////////////////////////////////////////////////////
  30. BOOL WINAPI ConsoleHandlerRoutine( DWORD dwCtrlType )
  31.  
  32. // Handle events on console
  33. //////////////////////////////////////////////////////////////////////////////////////
  34. {
  35.     switch ( dwCtrlType )
  36.     {
  37.     case CTRL_C_EVENT:
  38.         g_CtrlC = TRUE;
  39.         return TRUE;
  40.     }
  41.  
  42.     return FALSE;
  43. }
  44.  
  45. //////////////////////////////////////////////////////////////////////////////////////
  46. int main(int a_argc, char** a_argv)
  47.  
  48. // Process console commands.
  49. //////////////////////////////////////////////////////////////////////////////////////
  50. {
  51.     int     argc;                // number of arguments
  52.     TCHAR** argv;                // argument array
  53.  
  54. #ifdef UNICODE
  55.     // Create the unicode version of the command line
  56.     argv = CommandLineToArgvW( GetCommandLineW(), &argc);
  57.  
  58. #else
  59.     argc = a_argc;
  60.     argv = a_argv;
  61. #endif
  62.  
  63.     // Set some console parameters
  64.     SetConsoleTitle( TEXT("OlapDemo - Microsoft Sample for OLE DB for OLAP") );
  65.     SetConsoleCtrlHandler( ConsoleHandlerRoutine, TRUE );
  66.  
  67.     // Create and init olap application.
  68.     OLAPApp  app;
  69.     OLAPTab  tab;
  70.  
  71.     if ( FAILED(app.Init()) )
  72.         goto quit;
  73.  
  74.     TCHAR  string[OLAP_APP_MAX_STRING_LEN];
  75.  
  76.     while ( TRUE ) {
  77.         PrintPrompt(&app);
  78.  
  79.         memset( string, 0, sizeof(string) );
  80.         _getts(string);
  81.  
  82.         if ( g_CtrlC ) {
  83.             goto quit;
  84.         }
  85.  
  86.         if ( *string == 0 ) {
  87.             continue;
  88.         }
  89.  
  90.         // Process MDX statement. Rather than have the special keyword meaning "MDX query" we
  91.         // just look into the first word. We make sure no other keyword in this demo program
  92.         // is equal to these MDX keywords
  93.         if ( !OLAP_strcmp(string,6,_TEXT("Select"),6) ||
  94.              !OLAP_strcmp(string,4,_TEXT("With"),4)   || 
  95.              !OLAP_strcmp(string,4,_TEXT("Drop"),4)   || 
  96.              !OLAP_strcmp(string,6,_TEXT("Create"),6)    ) {
  97.             if ( FAILED(app.ExecQuery(string)) ) {
  98.                 tab.PrintError();
  99.             }
  100.             continue;
  101.         }
  102.  
  103.         // Process other commands
  104.  
  105.         if ( !tab.Set(string) ) {
  106.             _tprintf(TEXT("\nUnknown command!"));
  107.             continue;
  108.         }
  109.  
  110.         for ( LONG  i = 0, count = tab.GetColumns(); i < count; i++ ) {
  111.             LONG    length = tab.GetColumnLength(i);      
  112.             TCHAR*  text   = tab.GetColumnString(i);
  113.  
  114.             if ( !OLAP_strcmp(text,length,_TEXT("Exit"),OLAP_ALL) ||
  115.                  !OLAP_strcmp(text,length,_TEXT("E"),OLAP_ALL)    ||
  116.                  !OLAP_strcmp(text,length,_TEXT("Quit"),OLAP_ALL) ||
  117.                  !OLAP_strcmp(text,length,_TEXT("q"),OLAP_ALL)     ) {
  118.                 // Close application
  119.                 app.Disconnect();
  120.                 goto quit;
  121.             }
  122.             else if ( !OLAP_strcmp(text,length,_TEXT("Disconnect"),OLAP_ALL) ||
  123.                  !OLAP_strcmp(text,length,_TEXT("D"),OLAP_ALL)           ) {
  124.                 // Disconnect from server
  125.                 if ( FAILED(app.Disconnect()) ) {
  126.                     tab.PrintError();
  127.                     break;
  128.                 }
  129.             }
  130.             else if ( !OLAP_strcmp(text,length,_TEXT("Connect"),OLAP_ALL) ||
  131.                       !OLAP_strcmp(text,length,_TEXT("C"),OLAP_ALL)        ) {
  132.                 // Connect to server
  133.                 if ( FAILED(app.Connect(&string[length+1])) ) {
  134.                     tab.PrintError();
  135.                     break;
  136.                 }
  137.                 break;
  138.             }
  139.             else if ( !OLAP_strcmp(text,length,_TEXT("Use"),OLAP_ALL) ||
  140.                       !OLAP_strcmp(text,length,_TEXT("U"),OLAP_ALL)    ) {
  141.                 // Open DataBase
  142.                 if ( FAILED(app.OpenDataBase(&string[length+1])) ) {
  143.                     tab.PrintError();
  144.                     break;
  145.                 }
  146.                 break;
  147.             }
  148.             else if ( !OLAP_strcmp(text,length,_TEXT("Properties"),OLAP_ALL) || 
  149.                       !OLAP_strcmp(text,length,_TEXT("P"),OLAP_ALL)           ) {
  150.                 // Print properties
  151.                 DWORD    flags = 0;
  152.                 OLAPTab  table(NULL,TEXT(':'));
  153.  
  154.                 length = tab.GetColumnLength(++i);      
  155.                 text   = tab.GetColumnString(i);
  156.  
  157.                 while ( length && text ) {
  158.                     if ( !OLAP_strcmp(text,length,_TEXT("/NotSupported"),OLAP_ALL) ||
  159.                          !OLAP_strcmp(text,length,_TEXT("/n"),OLAP_ALL)             ) {
  160.                         flags |= DBPROPFLAGS_NOTSUPPORTED;
  161.                     }
  162.                     if ( !OLAP_strcmp(text,length,_TEXT("/Column"),OLAP_ALL) ||
  163.                          !OLAP_strcmp(text,length,_TEXT("/C"),OLAP_ALL)       ) {
  164.                         flags |= DBPROPFLAGS_COLUMN;
  165.                     }
  166.                     if ( !OLAP_strcmp(text,length,_TEXT("/DataSource"),OLAP_ALL) ||
  167.                          !OLAP_strcmp(text,length,_TEXT("/DS"),OLAP_ALL)          ) {
  168.                         flags |= DBPROPFLAGS_DATASOURCE;
  169.                     }
  170.                     if ( !OLAP_strcmp(text,length,_TEXT("/DataSourceCreate"),OLAP_ALL) ||
  171.                          !OLAP_strcmp(text,length,_TEXT("/DSC"),OLAP_ALL)               ) {
  172.                         flags |= DBPROPFLAGS_DATASOURCECREATE;
  173.                     }
  174.                     if ( !OLAP_strcmp(text,length,_TEXT("/DataSourceInfo"),OLAP_ALL) ||
  175.                          !OLAP_strcmp(text,length,_TEXT("/DSI"),OLAP_ALL)             ) {
  176.                         flags |= DBPROPFLAGS_DATASOURCEINFO;
  177.                     }
  178.                     if ( !OLAP_strcmp(text,length,_TEXT("/Init"),OLAP_ALL) ||
  179.                         !OLAP_strcmp(text,length,_TEXT("/I"),OLAP_ALL)      ) {
  180.                         flags |= DBPROPFLAGS_DBINIT;
  181.                     }
  182.                     if ( !OLAP_strcmp(text,length,_TEXT("/Index"),OLAP_ALL) ||
  183.                          !OLAP_strcmp(text,length,_TEXT("/Idx"),OLAP_ALL)    ) {
  184.                         flags |= DBPROPFLAGS_INDEX;
  185.                     }
  186.                     if ( !OLAP_strcmp(text,length,_TEXT("/Rowset"),OLAP_ALL) ||
  187.                          !OLAP_strcmp(text,length,_TEXT("/Row"),OLAP_ALL)     ) {
  188.                         flags |= DBPROPFLAGS_ROWSET;
  189.                     }
  190.                     if ( !OLAP_strcmp(text,length,_TEXT("/Session"),OLAP_ALL) ||
  191.                          !OLAP_strcmp(text,length,_TEXT("/S"),OLAP_ALL)        ) {
  192.                         flags |= DBPROPFLAGS_SESSION;
  193.                     }
  194.                     if ( !OLAP_strcmp(text,length,_TEXT("/Table"),OLAP_ALL) ||
  195.                          !OLAP_strcmp(text,length,_TEXT("/T"),OLAP_ALL)      ) {
  196.                         flags |= DBPROPFLAGS_TABLE;
  197.                     }
  198.                     if ( !OLAP_strcmp(text,length,_TEXT("/Read"),OLAP_ALL) ||
  199.                          !OLAP_strcmp(text,length,_TEXT("/R"),OLAP_ALL)     ) {
  200.                         flags |= DBPROPFLAGS_READ;
  201.                     }
  202.                     if ( !OLAP_strcmp(text,length,_TEXT("/Write"),OLAP_ALL) ||
  203.                          !OLAP_strcmp(text,length,_TEXT("/W"),OLAP_ALL)      ) {
  204.                         flags |= DBPROPFLAGS_WRITE;
  205.                     }
  206.                     if ( !OLAP_strcmp(text,length,_TEXT("/Required"),OLAP_ALL) ||
  207.                          !OLAP_strcmp(text,length,_TEXT("/Rq"),OLAP_ALL)        ) {
  208.                         flags |= DBPROPFLAGS_REQUIRED;
  209.                     }
  210.                     if ( !OLAP_strcmp(text,length,_TEXT("/Format"),OLAP_ALL) ||
  211.                          !OLAP_strcmp(text,length,_TEXT("/F"),OLAP_ALL)        ) {
  212.                         table.Set(tab.GetColumnString(++i));
  213.                     }
  214.                     length = tab.GetColumnLength(++i);      
  215.                     text   = tab.GetColumnString(i);
  216.                 }
  217.                 if ( FAILED(table.PrintPropertiesInfo(app.GetSource(),(flags) ? flags : -1)) ) {
  218.                     table.PrintError();
  219.                     break;
  220.                 }
  221.                 break;
  222.             }
  223.             else if ( !OLAP_strcmp(text,length,_TEXT("schema"),OLAP_ALL) ||
  224.                       !OLAP_strcmp(text,length,_TEXT("S"),OLAP_ALL)      ) {
  225.                 // Print schema rowset
  226.                 OLAPTab  table(NULL,TEXT(':'));
  227.                 TCHAR*   schema = NULL;
  228.  
  229.                 length = tab.GetColumnLength(++i);      
  230.                 text   = tab.GetColumnString(i);
  231.  
  232.                 while ( length && text ) {
  233.                     if ( !OLAP_strcmp(text,length,_TEXT("/Format"),OLAP_ALL) ||
  234.                          !OLAP_strcmp(text,length,_TEXT("/f"),OLAP_ALL)       ) {
  235.                         table.Set(tab.GetColumnString(++i));
  236.                     }
  237.                     else if ( *text == TEXT('/') ) {
  238.                          schema = text + 1;
  239.                     }
  240.                     length = tab.GetColumnLength(++i);      
  241.                     text   = tab.GetColumnString(i);
  242.                 }
  243.  
  244.                 if ( FAILED(table.PrintSchemaRowset(app.GetSession(),schema)) ) {
  245.                     table.PrintError();
  246.                     break;
  247.                 }
  248.                 break;
  249.             }
  250.             else if ( !OLAP_strcmp(text,length,_TEXT("Axis"),OLAP_ALL) ||
  251.                       !OLAP_strcmp(text,length,_TEXT("A"),OLAP_ALL)      ) {
  252.                 // Print axis rowset
  253.                 OLAPTab  table(NULL,TEXT(':'));
  254.                 TCHAR*   name = NULL;
  255.  
  256.                 length = tab.GetColumnLength(++i);      
  257.                 text   = tab.GetColumnString(i);
  258.  
  259.                 while ( length && text ) {
  260.                     if ( !OLAP_strcmp(text,length,_TEXT("/Format"),OLAP_ALL) ||
  261.                          !OLAP_strcmp(text,length,_TEXT("/f"),OLAP_ALL)       ) {
  262.                         table.Set(tab.GetColumnString(++i));
  263.                     }
  264.                     else if ( *text == TEXT('/') ) {
  265.                          name = text + 1;
  266.                     }
  267.                     length = tab.GetColumnLength(++i);      
  268.                     text   = tab.GetColumnString(i);
  269.                 }
  270.  
  271.                 if ( FAILED(table.PrintAxisRowset(app.GetDataset(),OLAP_ALL,name)) ) {
  272.                     tab.PrintError();
  273.                     break;
  274.                 }
  275.                 break;
  276.             }
  277.             else if ( !OLAP_strcmp(text,length,_TEXT("Cells"),OLAP_ALL) ||
  278.                       !OLAP_strcmp(text,length,_TEXT("CS"),OLAP_ALL)     ) {
  279.                 // Print cells of query
  280.                 OLAPTab  table(NULL,TEXT(':'));
  281.                 TCHAR*   schema = NULL;
  282.  
  283.                 length = tab.GetColumnLength(++i);      
  284.                 text   = tab.GetColumnString(i);
  285.  
  286.                 while ( length && text ) {
  287.                     if ( !OLAP_strcmp(text,length,_TEXT("/Format"),OLAP_ALL) ||
  288.                          !OLAP_strcmp(text,length,_TEXT("/f"),OLAP_ALL)       ) {
  289.                         table.Set(tab.GetColumnString(++i));
  290.                     }
  291.                     else if ( *text == TEXT('/') ) {
  292.                          schema = text;
  293.                     }
  294.                     length = tab.GetColumnLength(++i);      
  295.                     text   = tab.GetColumnString(i);
  296.                 }
  297.  
  298.                 if ( !OLAP_strcmp(schema,OLAP_ALL,_TEXT("/Query"),OLAP_ALL) ||
  299.                      !OLAP_strcmp(schema,OLAP_ALL,_TEXT("/q"),OLAP_ALL)    ) {
  300.                     if ( FAILED(table.PrintQuery(app.GetDataset())) ) {
  301.                         table.PrintError();
  302.                         break;
  303.                     }
  304.                 }
  305.                 else if ( FAILED(table.PrintDataset(app.GetDataset())) ) {
  306.                     table.PrintError();
  307.                     break;
  308.                 }
  309.                 break;
  310.             }
  311.             else if ( !OLAP_strcmp(text,length,_TEXT("Help"),OLAP_ALL) ||
  312.                       !OLAP_strcmp(text,length,_TEXT("?"),OLAP_ALL)     ) {
  313.                 // Help 
  314.                 OLAPTab  table(NULL,TEXT(':'));
  315.                 TCHAR*   help = NULL;
  316.  
  317.                 length = tab.GetColumnLength(++i);      
  318.                 text   = tab.GetColumnString(i);
  319.  
  320.                 if ( !length || !text ) {
  321.                     _tprintf(TEXT("\n\nFor more information on a specific command, type HELP command-name."));
  322.                     _tprintf(TEXT("\n[AXIS][A]              Print schema rowset."));
  323.                     _tprintf(TEXT("\n[CELLS][CS]            Print query result."));
  324.                     _tprintf(TEXT("\n[CONNECT][C]           Connect to OLAP Server."));
  325.                     _tprintf(TEXT("\nCreate                 MDX statement."));
  326.                     _tprintf(TEXT("\n[DISCONNECT][D]        Disconnect from OLAP server."));
  327.                     _tprintf(TEXT("\nDrop                   MDX statement."));
  328.                     _tprintf(TEXT("\n[EXIT][E][QUIT][Q]     Quits the OlapDemo.EXE program (OLAP Demo Application)."));
  329.                     _tprintf(TEXT("\n[PROPERTIES][P]        Print properties list."));
  330.                     _tprintf(TEXT("\nSelect                 MDX statement."));
  331.                     _tprintf(TEXT("\n[SCHEMA][S]            Print schema rowset."));
  332.                     _tprintf(TEXT("\n[USE][U]               Change current OLAP database."));
  333.                     _tprintf(TEXT("\nWith                   MDX statement."));
  334.                     _tprintf(TEXT("\n"));
  335.                     break;
  336.                 }
  337.  
  338.                 if ( !OLAP_strcmp(text,length,_TEXT("Exit"),OLAP_ALL) ||
  339.                      !OLAP_strcmp(text,length,_TEXT("E"),OLAP_ALL)    ||
  340.                      !OLAP_strcmp(text,length,_TEXT("Quit"),OLAP_ALL) ||
  341.                      !OLAP_strcmp(text,length,_TEXT("Q"),OLAP_ALL)     ) {
  342.                     // Close application
  343.                     _tprintf(TEXT("\nQuits the OlapDemo.EXE program (OLAP Demo Application)."));
  344.                     _tprintf(TEXT("\n\n[EXIT][E][QUIT][Q]"));
  345.                 }
  346.                 else if ( !OLAP_strcmp(text,length,_TEXT("Disconnect"),OLAP_ALL) ||
  347.                      !OLAP_strcmp(text,length,_TEXT("D"),OLAP_ALL)           ) {
  348.                     // Disconnect from server
  349.                     _tprintf(TEXT("\nDisconnect from OLAP server."));
  350.                     _tprintf(TEXT("\n\n[DISCONNECT][D]"));
  351.                 }
  352.                 else if ( !OLAP_strcmp(text,length,_TEXT("Connect"),OLAP_ALL) ||
  353.                           !OLAP_strcmp(text,length,_TEXT("C"),OLAP_ALL)        ) {
  354.                     // Connect to server
  355.                     _tprintf(TEXT("\nConnect to OLAP Server."));
  356.                     _tprintf(TEXT("\n\n[CONNECT][C] [servername][filename]"));
  357.                     _tprintf(TEXT("\n\nservername       Specifies the machine name of the server to connect."));
  358.                     _tprintf(TEXT("\nfilename         Specifies the path and name to DCube file to open."));
  359.                 }
  360.                 else if ( !OLAP_strcmp(text,length,_TEXT("Use"),OLAP_ALL) ||
  361.                           !OLAP_strcmp(text,length,_TEXT("U"),OLAP_ALL)    ) {
  362.                     // Open DataBase
  363.                     _tprintf(TEXT("\nChange current OLAP database."));
  364.                     _tprintf(TEXT("\n\n[USE][U] databasename"));
  365.                     _tprintf(TEXT("\n\ndatabase         Specifies the name of the database changed to active."));
  366.                 }
  367.                 else if ( !OLAP_strcmp(text,length,_TEXT("Properties"),OLAP_ALL) || 
  368.                           !OLAP_strcmp(text,length,_TEXT("P"),OLAP_ALL)           ) {
  369.                     // Print properties
  370.                     _tprintf(TEXT("\nPrint properties list."));
  371.                     _tprintf(TEXT("\n\n[PROPERTIES][P]"));
  372.                     _tprintf(TEXT(" [/notsupported][/n]"));
  373.                     _tprintf(TEXT(" [/column][/c]"));
  374.                     _tprintf(TEXT("\n   [/datasource][/ds]"));
  375.                     _tprintf(TEXT(" [/datasourcecreate][/dsc]"));
  376.                     _tprintf(TEXT(" [/datasourceinfo][/dsi]"));
  377.                     _tprintf(TEXT("\n   [/init][/i]"));
  378.                     _tprintf(TEXT(" [/index][/idx]"));
  379.                     _tprintf(TEXT(" [/rowset][/row]"));
  380.                     _tprintf(TEXT(" [/session][/s]"));
  381.                     _tprintf(TEXT(" [/table][/t]"));
  382.                     _tprintf(TEXT("\n   [/read][/r]"));
  383.                     _tprintf(TEXT(" [/write][/w]"));
  384.                     _tprintf(TEXT(" [/required][/rq]"));
  385.                     _tprintf(TEXT("\n   [/format][/f][c1:c2:c3...]"));
  386.                     _tprintf(TEXT("\n\n example:  p /ds /f 17:0:11"));
  387.                     _tprintf(TEXT("\n\nnotsupported           Specifies print not supported properties."));
  388.                     _tprintf(TEXT("\ncolumn                 Specifies print column properties."));
  389.                     _tprintf(TEXT("\ndatasource             Specifies print datasource properties."));
  390.                     _tprintf(TEXT("\ndatasourcecreate       Specifies print datasource create properties."));
  391.                     _tprintf(TEXT("\ndatasourceinfo         Specifies print datasource info properties."));
  392.                     _tprintf(TEXT("\ninit                   Specifies print init properties."));
  393.                     _tprintf(TEXT("\nindex                  Specifies print index properties."));
  394.                     _tprintf(TEXT("\nrowset                 Specifies print rowset properties."));
  395.                     _tprintf(TEXT("\nsession                Specifies print session properties."));
  396.                     _tprintf(TEXT("\ntable                  Specifies print table properties."));
  397.                     _tprintf(TEXT("\nread                   Specifies print read properties."));
  398.                     _tprintf(TEXT("\nwrite                  Specifies print write properties."));
  399.                     _tprintf(TEXT("\nrequired               Specifies print required properties."));
  400.                     _tprintf(TEXT("\nformat                 Use specified number of characters for column then print."));
  401.                 }
  402.                 else if ( !OLAP_strcmp(text,length,_TEXT("schema"),OLAP_ALL) ||
  403.                           !OLAP_strcmp(text,length,_TEXT("S"),OLAP_ALL)      ) {
  404.                     // Print schema rowset
  405.                     _tprintf(TEXT("\nPrint schema rowset."));
  406.                     _tprintf(TEXT("\n\n[SCHEMA][S] schemaname"));
  407.                     _tprintf(TEXT("\n   [/format][/f][c1:c2:c3...]"));
  408.                     _tprintf(TEXT("\n\n examples:  s /c /f 0:20"));
  409.                     _tprintf(TEXT("\n            s /cub /f 0:0:0:20:15:0:0:0:0:0:0"));
  410.                     _tprintf(TEXT("\n            s /dim /f 0:0:0:25:20"));
  411.                     _tprintf(TEXT("\n            s /h /f 0:0:0:25:25:0"));
  412.                     _tprintf(TEXT("\n            s /l /f 0:0:0:25:25:25:20:0:0:20:0:0"));
  413.                     _tprintf(TEXT("\n            s /mem /f 0:0:0:10:20:0:30:0:0:20:50:0:0:0:0:0"));
  414.                     _tprintf(TEXT("\n            s /p /f 0:0:0:0:0:0:0:0:15:15:0:10:0:0:0:0"));
  415.                     _tprintf(TEXT("\n\nschemaname             Specifies name of schema for print."));
  416.                     _tprintf(TEXT("\n       [/catalogs][/c],"));
  417.                     _tprintf(TEXT("\n       [/cubes][/cub],"));
  418.                     _tprintf(TEXT("\n       [/dimensions][/dim],"));
  419.                     _tprintf(TEXT("\n       [/hierarchies][/h],"));
  420.                     _tprintf(TEXT("\n       [/levels][/l],"));
  421.                     _tprintf(TEXT("\n       [/measures][/m],"));
  422.                     _tprintf(TEXT("\n       [/members][/mem],"));
  423.                     _tprintf(TEXT("\n       [/properties][/p]."));
  424.                     //_tprintf(TEXT("\n       [/schemas][/s]."));
  425.                     _tprintf(TEXT("\nformat                 Use specified number of characters for column then print."));
  426.                 }
  427.                 else if ( !OLAP_strcmp(text,length,_TEXT("Axis"),OLAP_ALL) ||
  428.                           !OLAP_strcmp(text,length,_TEXT("A"),OLAP_ALL)      ) {
  429.                     // Print axis rowset
  430.                     _tprintf(TEXT("\nPrint axis rowset."));
  431.                     _tprintf(TEXT("\n\n[AXIS][A] axisname"));
  432.                     _tprintf(TEXT("\n   [/format][/f][c1:c2:c3...]"));
  433.                     _tprintf(TEXT("\n\n example:  a /0 /f 0:15:35:30:30:0:0"));
  434.                     _tprintf(TEXT("\n\nquery                 Specifies print not supported properties."));
  435.                     _tprintf(TEXT("\n\naxisname              Specifies name of axis for print."));
  436.                     _tprintf(TEXT("\n       [/columns][/0],"));
  437.                     _tprintf(TEXT("\n       [/rows][/1],"));
  438.                     _tprintf(TEXT("\n       [/2],"));
  439.                     _tprintf(TEXT("\n       [/3],"));
  440.                     _tprintf(TEXT("\n       [/4],"));
  441.                     _tprintf(TEXT("\n       [/5],"));
  442.                     _tprintf(TEXT("\n       [/6],"));
  443.                     _tprintf(TEXT("\n       [/7]."));
  444.                     _tprintf(TEXT("\nformat                 Use specified number of characters for column then print."));
  445.                 }
  446.                 else if ( !OLAP_strcmp(text,length,_TEXT("Cells"),OLAP_ALL) ||
  447.                           !OLAP_strcmp(text,length,_TEXT("CS"),OLAP_ALL)     ) {
  448.                     // Print cells of query
  449.                     _tprintf(TEXT("\nPrint query result."));
  450.                     _tprintf(TEXT("\n\n[CELLS][CS] [/Query][/q]"));
  451.                     _tprintf(TEXT("\n   [/format][/f][c1:c2:c3...]"));
  452.                     _tprintf(TEXT("\n\n examples:  cs /f 20:0"));
  453.                     _tprintf(TEXT("\n            cs /q"));
  454.                     _tprintf(TEXT("\n\nquery                  Specifies use of axes query result for print."));
  455.                     _tprintf(TEXT("\nformat                 Use specified number of characters for column then print."));
  456.                 }
  457.                 else {
  458.                     _tprintf(TEXT("\nUnknown command!"));
  459.                 }
  460.                 break;
  461.             }
  462.             else  {
  463.                 _tprintf(TEXT("\nUnknown command!"));
  464.                 break;
  465.             }
  466.         }
  467.     }
  468.  
  469. quit:
  470.     return 0;
  471. }
  472.  
  473. //////////////////////////////////////////////////////////////////////////////////////
  474. void    PrintPrompt( OLAPApp*  app )
  475.  
  476. // Process console commands.
  477. //////////////////////////////////////////////////////////////////////////////////////
  478. {
  479.     if ( app && app->IsState(OLAP_APP_CONNECTED) ) {
  480.         VARIANT  server;
  481.         VARIANT  database;
  482.  
  483.         VariantInit( &server );
  484.         VariantInit( &database );
  485.  
  486.         app->GetProperty( DBPROPSET_DATASOURCEINFO, DBPROP_SERVER_NAME, &server );
  487.         app->GetProperty( DBPROPSET_DATASOURCE, DBPROP_CURRENTCATALOG, &database );
  488.  
  489.         _tprintf(TEXT("\n"));
  490.  
  491.         switch ( V_VT(&server) )  {
  492.         case VT_BSTR:    
  493.         case VT_LPSTR:
  494.         case VT_LPWSTR:
  495.             _tprintf(TEXT("%s"), V_BSTR(&server));
  496.             break;
  497.         case VT_BSTR    | VT_BYREF:    
  498.         case VT_LPSTR    | VT_BYREF:
  499.         case VT_LPWSTR    | VT_BYREF:     
  500.             _tprintf(TEXT("%s"), *V_BSTRREF(&server));
  501.             break;
  502.         default:
  503.             _tprintf(TEXT(" ?"));
  504.         }
  505.  
  506.         switch ( V_VT(&database) )  {
  507.         case VT_BSTR:    
  508.         case VT_LPSTR:
  509.         case VT_LPWSTR:
  510.             _tprintf(TEXT(" [%s]"), V_BSTR(&database));
  511.             break;
  512.         case VT_BSTR    | VT_BYREF:    
  513.         case VT_LPSTR    | VT_BYREF:
  514.         case VT_LPWSTR    | VT_BYREF:     
  515.             _tprintf(TEXT(" (%s)"), *V_BSTRREF(&database));
  516.             break;
  517.         default:
  518.             _tprintf(TEXT(" ?"));
  519.         }
  520.         _tprintf(TEXT(">"));
  521.  
  522.         VariantClear( &server );
  523.         VariantClear( &database );
  524.         return;
  525.     }
  526.     _tprintf(TEXT("\nOlapDemo>"));
  527. }