In The Recordset Object, I've shown an example of how to retrieve the Properties collection of either the active Connection or Recordset object.
This section includes two other utilities you may find some use for as you work with databases and data access pages. Of course, similar functionalities may also be available in the RDBMS itself where the database was created.
The ADO Connection object includes the OpenSchema method to obtain database schema information from the data source provider, such as the Name, Type and Columns of each Table or View in the database.
An earlier sample has shown use of the method to enable selection from a list of the available tables and views. Here is a simple way to gather and display that information in tabular form, useful for quickly browsing the contents of any database.
An ADO Recordset object has a collection of Field objects, each corresponding to a column in the Recordset.
Each Field object contains information about its metadata properties ( Name, Type, DefinedSize, Precision, and NumericScale ), which are useful when dynamically constructing data-bound forms. The sample shows a simple way to gather that information from the Field objects of any given Recordset.
Well, that's about it for this session. Hopefully at least, you've gained some extra helpful hints to fill your bag of tricks.
Modesty aside, though, the samplers presented in this section involve simple, power features that can surely find use in varied data-based apps.
Using queries with the generic methods, the pages can serve as reusable templates that can be adopted for most uses, simply by changing the data source. Of course, they can further be enhanced, but I wouldn't want to spoil the fun, so I'll leave that up to you.
Next in this series:
If you haven't done so, I suggest you start with:
ADO Primer: Letting users search for information