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
Aug 27, 1999

Read Metadata With OpenSchema

Question:
How do I read the names of tables and fields in an Access database? I tried OpenSchema, but I got the error, "The operation requested by the application is not supported by the provider."

Answer:

Your problem is in the Connection String you are using. On your Web server, you probably do not have the correct Access provider files installed. Instead, try using an ODBC connection. For example, to open an Access database and read tables, use this code. (Replace "FullpathnameofyourMDBfile" with the appropriate path as viewed from your Web server, not your development machine, if it is different).

   Dim cnn1, rstSchema, strCnn 
   Const adSchemaTables = 20
      
   Set cnn1 = Server.Createobject("ADODB.Connection")
   strCnn = "DRIVER=Microsoft Access Driver (*.mdb);Persist Security Info=False;DBQ=FullpathnameofyourMDBfile;DefaultDir=FullDirectoryNameOfyourMDBfile"
   cnn1.Open strCnn
      
   Set rstSchema = cnn1.OpenSchema(adSchemaTables)
   
   Do Until rstSchema.EOF
      Response.write "Table name: " & _
         rstSchema("TABLE_NAME") & " = "  & _
         "Table type: " & rstSchema("TABLE_TYPE") & "
" rstSchema.MoveNext Loop rstSchema.Close cnn1.Close set cnn1 = nothing

Note that you will get all Tables, including Access System tables from this code.

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