|
 |
asp_databases thread: Need to pull all table names from a DB in ASP
Message #1 by "Mark Weisberger" <mark707@a...> on Thu, 31 May 2001 16:52:35
|
|
Does anyone know the code to pull all of the table names from a DB using
ASP? I want to pull all the table names of a DB and put them in a HTML
select list. I appreciate any help you can provide. Thank you!
Message #2 by "info" <info@p...> on Thu, 31 May 2001 12:27:13 -0400
|
|
<%
Dim Connect, Recordset, Connection
Connect = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=c:\database.mdb;Persist Security Info=False"
Set Connection = Server.CreateObject("ADODB.Connection")
Connection.Open Connect
Set Recordset = Connection.OpenSchema(20) ' adSchemaTables
' Loop through the results and print
Do Until Recordset.EOF
If Recordset.Fields("TABLE_TYPE") = "TABLE" Then
Response.Write "<option value='" & Recordset.Fields("TABLE_NAME") &
"'>" & Recordset.Fields("TABLE_NAME") & "</option>"
End If
Recordset.MoveNext
Loop
Recordset.Close
Connection.Close
Set Recordset = Nothing
Set Connection = Nothing
%>
---- Original Message ----
From: mark707@a...
To: asp_databases@p...,
Subject: RE: [asp_databases] Need to pull all table names from a DB
in ASP
Date: Thu, 31 May 2001 16:52:35
>Does anyone know the code to pull all of the table names from a DB
>using
>ASP? I want to pull all the table names of a DB and put them in a
>HTML
>select list. I appreciate any help you can provide. Thank you!
>
Message #3 by "Dallas Martin" <dmartin@z...> on Thu, 31 May 2001 13:27:45 -0400
|
|
Here's How:
<%
'*** Create and Open connection
set cnConn = Server.CreateObject("ADODB.Connection")
strConn = Application("strConn")
cnConn.Open(strConn)
set rsCOLS = cnConn.OpenSchema(4)
response.write("<table border=0 cellpadding=5>")
table_name = rsCOLS.Fields("TABLE_NAME")
response.write("<tr><td><b>")
response.write(ucase(rsCOLS.Fields("TABLE_NAME")))
response.write("</b></td>")
while not rsCOLS.eof
if table_name <> rsCOLS.Fields("TABLE_NAME") then
response.write("</tr></table>")
table_name = rsCOLS.Fields("TABLE_NAME")
response.write("<table border=0 cellspacing=5>")
response.write("<tr><td><b>")
response.write(ucase(rsCols.Fields("TABLE_NAME")))
response.write("</b></td>")
end if
response.write "<td>"
response.write(lcase(rsCols.fields("column_name")))
response.write("</td>")
rsCols.MoveNext
wend
response.write("</tr></table>")
rsCols.close
set rsCols = nothing
cnConn.Close
set cnConn = nothing
response.end
%>
Dallas Martin
----- Original Message -----
From: "Mark Weisberger" <mark707@a...>
To: "ASP Databases" <asp_databases@p...>
Sent: Thursday, May 31, 2001 4:52 PM
Subject: [asp_databases] Need to pull all table names from a DB in ASP
> Does anyone know the code to pull all of the table names from a DB using
> ASP? I want to pull all the table names of a DB and put them in a HTML
> select list. I appreciate any help you can provide. Thank you!
>
|
|
 |