The code I'm presenting today has some additions to the OLE DB Client library, namely some new schema-related classes:
- CSchema - Contains an array of table CTableSchema objects and a reference to a CSession.
- CTableSchema - Contains a table schema information. This class is prepared to load this information on demand in order to avoid a performance penalty when enumerating the database schema (all tables are loaded and each table schema is loaded on demand).
- CTableDefinition - Helper class that loads the table definition in a single OLE DB call. This populates the columns and constraints collections. Indexes are loaded separately through a specialized schema rowset (see the LoadIndexes method).
- CColumn - Contains column schema information.
- CIndex - Contains index schema information and a list of index columns.
- CIndexColumn - An individual index column.
The sample project is the same - it enumerates in a tree the schema of the sample database placed on the device root. As you can see from the code, the tree lazily loads the table schema information (when the user expands either the "Columns" or the "Indexes" folder).
After loking a bit at this sample and to how the OLE DB Client has evolved, I started wondering about writing a "Query Analyzer" type of application. This would mimick most of the "old" SQL Compact Query Analyzer application and would add a few more features. Writing this application would require development in other areas such as the user interface, but I think that it will be a very interesting challenge.
What features would you like to see in the open source QA? What name would you give such app?
Sample: SchemaTree2.zip (1.21 MB)