When you think ASP, think...
Recent Articles
All Articles
ASP.NET Articles
Related Web Technologies
User Tips!
Coding Tips

Sample Chapters
JavaScript Tutorials
MSDN Communities Hub
Official Docs
Stump the SQL Guru!
XML Info
Author an Article
Print this page.
Published: Tuesday, September 22, 1998

Listing the Tables in an Access MDB Database Using ASP

Let's say that you are using an Access database on your web page, and are using Active Server Pages to interact with the database. Now let's say that your boss wants you to write an informational, administrative page, which lists all of the tables in the database via an ASP page, similar to the way the Analyzer works in Access. You may be sweating bullets by now, but you really shouldn't be, because listing tables in an Access database is not an impossible task. From the Active Server Pages mailing lis t, it is asked if it is possible to list the tables in an Access MDB file. The question is answered by Manfred Stanfield.

- continued -

Listing the Tables in an Access MDB Database Using ASP:
The question is very short and simple indeed:

From ASP, is it possible to list the tables in an Access MDB file?

And the answer by Mr. Stanfield:

Here this will work:

Function ConnectODBC( ConnectionObject )
      Set ConnectionObject = Server.CreateObject("ADODB.Connection")
      ConnectionObject.ConnectionTimeout = Session("JobTracking_ConnectionTimeout")
      ConnectionObject.CommandTimeout = Session("JobTracking_CommandTimeout")
      ConnectionObject.CommandTimeout = 3000
End Function

Const adSchemaTables = 20

ConnectODBC oConn
Set rstSchema = oConn.OpenSchema(adSchemaTables)
Do Until rstSchema.EOF
      Response.Write "Table name: " & rstSchema("TABLE_NAME") & vbCr & "Table type: " & rstSchema("TABLE_TYPE") & vbCr & "<BR>"

As you can see, it is quite possible to list the tables in an Access database. You just need to access the database's schema object, which can be done quite simply through ASP. In fact, Access allows you to examine more than just table names- you can vi ew table descriptions, column datatypes, column rules, min. and max values, etc. While this table-level data is available in SQL, it is much more of a hassle to obtain it than it is through Access. If only Access were more secure and efficient.... alas. Happy Programming!

ASP.NET [1.x] [2.0] | ASPFAQs.com | Advertise | Feedback | Author an Article