devxlogo

Read Metadata With OpenSchema

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.

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist