|
Listing Tables within Databases by
Charles Carroll DRAFT
SQL Server allows you to list tables like this:
filename=/learn/test/sqlservertablelist.asp
<HEAD><TITLE>sqlservertablelist.asp</TITLE></HEAD>
<HTML><body bgcolor="#FFFFFF">
<%
whichDSN="DSN=student;uid=student;pwd=magic"
call query2table("select name,type from sysobjects where type='U'", whichDSN)
%>
<!--#include virtual="/learn/test/lib_dbtable.asp"-->
</BODY></HTML>
Access allows you to list tables like this (assuming
you allow system objects to be visible within the database on the Access side):
filename=/learn/test/accesstablelist.asp
<HEAD><TITLE>accesstablelist.asp</TITLE></HEAD>
<HTML><body bgcolor="#FFFFFF">
<%
whichDSN="DRIVER={Microsoft Access Driver (*.mdb)}; "
whichDSN=whichDSN & "DBQ=" & server.mappath("/learn/test/biblio.mdb")
call query2table("select * from MsysObjects WHERE type = 1",whichDSN)
%>
<!--#include virtual="/learn/test/lib_dbtable.asp"-->
</BODY></HTML>
The Include file looks like this:
filename=/learn/test/lib_dbtable.asp
<%
sub query2table(inputquery, inputDSN)
dim conntemp, rstemp
set conntemp=server.createobject("adodb.connection")
conntemp.open inputDSN
set rstemp=conntemp.execute(inputquery)
howmanyfields=rstemp.fields.count -1%>
<table border=1><tr>
<% 'Put Headings On The Table of Field Names
for i=0 to howmanyfields %>
<td><b><%=rstemp(i).name%></B></TD>
<% next %>
</tr>
<% ' Now lets grab all the records
do while not rstemp.eof %>
<tr>
<% for i = 0 to howmanyfields
thisvalue=rstemp(i)
If isnull(thisvalue) then
thisvalue=" "
end if%>
<td valign=top><%=thisvalue%></td>
<% next %>
</tr>
<%rstemp.movenext
loop%>
</table>
<%
rstemp.close
set rstemp=nothing
conntemp.close
set conntemp=nothing
end sub%>
 |  |  |
 |
There are many worthy charities!!. But perhaps help starving children in Africa or South America AND help Charles too.
a $5 tip buys him lunch at McDonalds,
a $20 tip buys his kid Hitoshi a new computer game,
a $39 tip buys his daughter Michiko a few nice outfits.
See our donor list.
|  |
 |  |  |
|
|
|
|