Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get table names, ADO, jet sql

Status
Not open for further replies.

sunaj

Technical User
Feb 13, 2001
1,474
0
0
DK

I'm using ADO 2.5 in VB to create and search in a database.

I would like to ask the database the names of the tables and the name of the database. In MySQL this would be SHOW DATABASES and SHOW TABLES, but what is it in JET SQL or is there an ADO way to do it?

Thanks,
Sunaj
 
Use ADOX, through which you can get all the catalog information.

Hope this helps
 
Here is one solution. Enjoy...

<% Option Explicit %>
<!--#include file=&quot;adovbs.inc&quot;-->
<%
' LISTS ALL TABLES AND COLUMN NAMES

Dim objADOXDatabase
Set objADOXDatabase = Server.CreateObject(&quot;ADOX.Catalog&quot;)

objADOXDatabase.ActiveConnection = &quot;Provider=Microsoft.Jet.OLEDB.4.0;&quot; & _
&quot;Data Source=d:/blahblah/blagblah/uselessdata.mdb&quot;

Dim objTable, objColumn
For Each objTable in objADOXDatabase.Tables
If objTable.Type = &quot;TABLE&quot; then
'Response.Write objTable.Name & &quot;<br>&quot;

For Each objColumn in objTable.Columns
Response.Write &quot;&nbsp;&nbsp;&nbsp;&quot; & objColumn.Name & &quot;<br>&quot;
Next

Response.Write &quot;<p>&quot;
End If
Next

Set objADOXDatabase = Nothing
%>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top