Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Active Server Pages (ASP)
Expertise: Beginner
Sep 29, 1999

Retrieve Table Names From an Access Database

Question:
How do I retrieve all the table names from an Access database using ASP?

Answer:

Make sure you have an ODBC DSN to point to your database. Then use this code to output all the tables in the database:

' -- Declare variables
Dim objConn, objRS
' -- Declare constants
Const adSchemaTables = 20
' -- create objects
Set objConn = Server.CreateObject("ADODB.Connection")
set objRS = Server.CreateObject("ADODB.Recordset")

' -- Open the connection: replace values with 
' -- your system's values
objConn.Open "DSNName", "UserID", "Password"

' -- Get list of tables - ALL tables
set objRS = objConn.OpenSchema(adSchemaTables)
' -- Walk the recordset
Do While Not objRS.EOF		
   ' -- output table name and table type
   Response.write "Table Name = " & objRS("TABLE_NAME") & " Table Type = " & objRS("TABLE_TYPE") & "
" ' -- next record objRS.MoveNext Loop ' -- Close all objects objRS.Close set objRS = Nothing objConn.Close set objConn = Nothing
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date