Execute o código abaixo e veja os detalhes do seu banco de dados. Não esqueça de acertar o caminho para o seu banco de dados.. =]
<%
Option Explicit
dim Conn ' Conexao com o banco de dados
dim rstSchema ' Detalhes da tabela
dim rstColumns ' Detalhes das colunas
dim ColumnsTypes ' Propriedades dos campos a serem mostradas
dim x ' Para loop de campos
dim rows ' Para visual "zebrado"
dim valor ' Valor do campo
set conn = server.CreateObject("ADODB.Connection")
Conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.mappath( "../database/bdados.mdb" )
Conn.Open
response.buffer = false
%>
<html>
<head>
<title>Database structure for <%= server.mappath( "database/bdados.mdb" ) %></title>
<style type=text/css>
.color0 { background-color: #333333; color: white; }
.color1 { background-color: #666666; }
.color2 { background-color: #999999; }
.color3 { background-color: #BBBBBB; }
body, table, td, tr { font-family: verdana; font-size: 10pt; }
</style>
</head>
<body>
<table cellspacing=2>
<%
ColumnsTypes = array( "COLUMN_NAME", "DATA_TYPE", "COLUMN_FLAGS", "IS_NULLABLE", _
"CHARACTER_MAXIMUM_LENGTH", "NUMERIC_PRECISION", "NUMERIC_SCALE", _
"DATETIME_PRECISION", "COLUMN_DEFAULT", "DESCRIPTION" )
Set rstSchema = Conn.OpenSchema( adSchemaTables, array( empty, empty, empty, "TABLE" ) )
do while not rstSchema.EOF %>
<tr>
<td colspan=<%= uBound( ColumnsTypes ) + 1 %> class=color0>
<b>
TABLE_NAME: <%= rstSchema( "TABLE_NAME" ) %><br>
TABLE_TYPE: <%= rstSchema( "TABLE_TYPE" ) %>
</b>
</td>
</tr>
<tr class=color1>
<%
set rstColumns = Conn.OpenSchema( adSchemaColumns, array( empty, empty, rstSchema("table_name" ).value ) )
for x = 0 to ubound(ColumnsTypes)
response.write " <td align=center><small>" & ColumnsTypes( x ) & "</small></td>" & vbcrlf
next %>
</tr><%
rows = 0
do while not rstColumns.eof %>
<tr class=color<%= iif( rows mod 2, 2, 3 ) %>>
<%
for x = 0 to ubound(ColumnsTypes)
valor = rstColumns( ColumnsTypes(x) )
if ColumnsTypes(x) = "DATA_TYPE" then
valor = TypeName( valor )
else
if isNull( valor ) then valor = "-"
end if
response.write " <td align=center>" & valor & "</td>" & vbcrlf
next
rstColumns.movenext %>
</tr><%
rows = rows + 1
loop
rstColumns.close
set rstColumns = nothing
rstSchema.MoveNext
Loop
rstSchema.close
set rstSchema = nothing
function iif( condicao, valor1, valor2 )
if condicao then iif = valor1 else iif = valor2 end if
end function
function TypeName( value )
select case value
case adEmpty : TypeName = "Empty"
case adTinyInt : TypeName = "TinyInt"
case adSmallInt : TypeName = "SmallInt"
case adInteger : TypeName = "Integer"
case adBigInt : TypeName = "BigInt"
case adUnsignedTinyInt : TypeName = "UnsignedTinyInt"
case adUnsignedSmallInt : TypeName = "UnsignedSmallInt"
case adUnsignedInt : TypeName = "UnsignedInt"
case adUnsignedBigInt : TypeName = "UnsignedBigInt"
case adSingle : TypeName = "Single"
case adDouble : TypeName = "Double"
case adCurrency : TypeName = "Currency"
case adDecimal : TypeName = "Decimal"
case adNumeric : TypeName = "Numeric"
case adBoolean : TypeName = "Boolean"
case adError : TypeName = "Error"
case adUserDefined : TypeName = "UserDefined"
case adVariant : TypeName = "Variant"
case adIDispatch : TypeName = "IDispatch"
case adIUnknown : TypeName = "IUnknown"
case adGUID : TypeName = "GUID"
case adDate : TypeName = "Date"
case adDBDate : TypeName = "DBDate"
case adDBTime : TypeName = "DBTime"
case adDBTimeStamp : TypeName = "DBTimeStamp"
case adBSTR : TypeName = "BSTR"
case adChar : TypeName = "Char"
case adVarChar : TypeName = "VarChar"
case adLongVarChar : TypeName = "LongVarChar"
case adWChar : TypeName = "WChar"
case adVarWChar : TypeName = "VarWChar"
case adLongVarWChar : TypeName = "LongVarWChar"
case adBinary : TypeName = "Binary"
case adVarBinary : TypeName = "VarBinary"
case adLongVarBinary : TypeName = "LongVarBinary"
end select
end function
%>
</table>
</body>
</html>
<!-- #include virtual="adovbs.inc" -->
0 comentários:
Postar um comentário