Have you ever wanted to be able to list your database's tables and columns on your intranet or Internet site? One option is to take a snapshot of your database design and post it to your Web. Or, using Schemas, you can have a live picture of your database on the Web!
To obtain a listing of the tables in a SQL Server database, you can use the sysobjects
table. We discussed using this technique in an article entitled, "
Using the sysobjects Table." However, what if you wanted to list the tables and
columns in an Access database? Or a FoxPro database? Or an Oracle database? Or an Informix database? Or
any ODBC-compliant database?
To retrieve database information from a wide array of data sources, you will need to use a schema. A schema is database information (in Recordset object format), from tables, to columns, to indexes, to constraints, and all sorts of other neat information.
To open a schema, you need to use the OpenSchema method of the Connection
object. This returns a schema (in Recordset format), that contains certain information on the
database that the Connection object points to. So, if you open the Schema adSchemaTables,
you will receive information on the tables.
| For more information on listing database system information, be sure to read: Programmatically Determining if a Table Exists and Determining the Creation Date of Tables! |
Here is some code that will list all of the tables and columns in your database... Have fun with it!
Run this Example!
<%@ Language = VBSCRIPT %>
| |||||||||||||||||||||
Attachments:




