aspxtreme

Displaying information from a database

ADO Primer   Section Index


Retrieving properties of a database

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.

Checking the name, type, and columns of each table in a database

Connection OpenSchema Method
Run Sample | View Source

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.

Checking the fields structure of a given table

Recordset Fields Collection
Run Sample | View Source

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: Part I
    • Basic database concepts
    • Connecting to a database
    • The Recordset object
See Also

ADO Primer: Letting users search for information



Books and more ...


Suggested Reading

Need a break ?



Back to top

Check out related books at Amazon

© 2000-2008 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support aspxtreme