Programming :  Student Freelance Forum For Work Experience Builders' (CertificationPoint) The fastest message board... ever.
 
CLASSIC ASP_Display Information About a Microsoft Access Database
Posted by: adcertpoint (Moderator)
Date: April 29, 2020 04:44PM

The following block of code will display the properties of ALL tables in a MicrosoftAccess database. For the code to run successfully, the variable MyConnectionString needs to contain avalid connection string pointing to the Access database.
Withthis code, all tables, including system tables are displayed. If you want tolimit the list, use myTable.Type todetermine the type of the table and skip the system tables. User tables willreturn "TABLE", while system tables will return "ACCESS TABLE".

If you want to display information about just a single table, remove the For Each loop and uncomment the line that starts with Set myTable. Don't forget the pass the name of the right table to the Tables collection.



<%
' Create a Catalog Object and open the Table
Dim myCatalog
Dim myTable
Dim myProperty
Dim MyColumn
Set myCatalog = Server.CreateObject("ADOX.Catalog"winking smiley
myCatalog.ActiveConnection = MyConnectionString

' Set myTable = myCatalog.Tables("myTable"winking smiley

For Each myTable in myCatalog.Tables %>
<h1>Table Name: <%=myTable.name%></h1>
<h2>Table Properties</h2>
<table border="1">
<tr>
<td><strong>Name</strong></td>
<td><strong>Value</strong></td>
</tr>
<% For Each myProperty in myTable.Properties %>
<tr>
<td><%=myProperty.Name%></td>
<td><%=myProperty.Value%></td>
</tr>
<% Next %>
<tr>
<td>
Type
</td>
<td>
<%=myTable.Type%>
</td>
</tr>
</table>
<br />
<br />
<h2>Column Properties</h2>
<table border="1">
<tr>
<td>Name</td>
<td>Type</td>
<td>Defined Size</td>
<td>Numeric Scale</td>
<td>Precision</td>
<td>Properties</td>
</tr>
<% For Each MyColumn in myTable.Columns %>
<tr>
<td><%=MyColumn.Name%></td>
<td><%=MyColumn.Type%></td>
<td><%=MyColumn.DefinedSize%></td>
<td><%=MyColumn.NumericScale%></td>
<td><%=MyColumn.Precision%></td>
<td>
<table border ="1">
<tr>
<td>Property Name</td>
<td>Property Value</td>
</tr>
<% For each MyProperty in MyColumn.Properties %>
<tr>
<td><%=MyProperty.Name%></td>
<td><%=MyProperty.Value%></td>
</tr>
<% Next %>
</table>
</td>
</tr>
<% Next %>
</table>
<% Next %>
%>

Options: ReplyQuote


Sorry, only registered users may post in this forum.
This forum powered by Phorum.