如何显示数据库的结构?

htmlheadmeta “Content-Type” content=”text/html; charset=gb2312″/headbody
bgcolor=”#CCCCCC” text=”#000000″h2
align=”center”星河影动之查看数据库结构/h2p %on error resume
nexttable=request(“table”)’ 获得表名.

是建立一个数据集
前面应该先定义此数据集
dim rs as adodb.recordset
然后就可以用
set rs=server.CreateObject(“adodb.recordset”)
来建立一个数据集的实例,当然此时数据集中是没有数据的
rs.open ……
来打开一个记录集
rs.append或者rs.insert来添加记录
rs.edit来修改记录
对于添加或修改的记录,可以用
rs.fields(“字段名”)=xxx
来进行赋值
rs.update
把更改过的值更新回数据库
当你添加一个数据(rs1)进数据库时:
rs.addnew
rs(“rs1″)=”添加的数据”
rs.update
rs.close
set rs=nothing
下面我们来个实例:
Set mRs= Server.CreateObject(“adodb.recordSet”)
mRs.open “Select * from book”, conn, 1, 3
mRs.addnew
mRs(“Name”) = Name
mRs(“Mail”) = Mail
mRs(“Qq”) = Qq
mRs(“Info”) = Info
mRs(“time”) = now()
mRs.update
mRs.close
Set mRs = nothing
//下面是调用html输入框

if table”” thenresponse.write “数据表:”&tableSet primary =
con.OpenSchema(adSchemaPrimaryKeys, _Array(empty, empty, table))if
primary(“COLUMN_NAME”)”” thenprimarykey=primary(“COLUMN_NAME”)end
ifprimary.closeset primary=nothing%/pcentertable width=”650″ border=”1″
cellpadding=”0″ cellspacing=”0″tr bgcolor=”#CCCCCC” th width=”61″ div
align=”center”字段/div/thth width=”131″ div align=”center”类型/div/thth
width=”105″ div align=”center”设定大小/div/thth width=”69″ div
align=”center”允许空值/div/thth width=”69″ 自动编号/thth
width=”81″主键/th/tr%sql=”select * from [“&table&”] “set
rs=con.execute(sql)for i=0 to rs.fields.count-1%tr bgcolor=”#CCCCCC” td
height=”2″ width=”61″ div align=”center”%=rs(i).name%/div

<table border=”0″ cellpadding=”0″ style=”border-collapse: collapse”
width=”100%”>
<form name=”form1″ method=”post” action=”admin/<% =filename
%>?action=Reply&id=<% =id %>”>
<tr>
<td width=”118″ height=”37″ align=”center”
bgcolor=”#EFEFEF”>昵称:</td>
<td width=”640″>
<input name=”Name” type=”text” class=”input” value=”<%
=mRs(“Name”) %>”>
</td>
</tr>
<tr>
<td width=”118″ height=”37″ align=”center”
bgcolor=”#EFEFEF”>内容是否公开:</td>
<td width=”640″>
<input type=”radio” name=”Qq” value=”1″ <%if mRs(“qq”)=1 then
response.write ” checked ” end if%> >

<input name=”Qq” type=”radio” value=”0″ <%if mRs(“qq”)=0 then
response.write ” checked ” end if%> >
否 </td>
</tr>
<tr>
<td width=”118″ height=”37″ align=”center”
bgcolor=”#EFEFEF”>邮箱:</td>
<td width=”640″>
<input name=”Mail” type=”text” class=”input” value=”<%
=mRs(“Mail”) %>”>
</td>
</tr>
<tr>
<td width=”118″ height=”37″ align=”center”
bgcolor=”#EFEFEF”>留言:</td>
<td width=”640″>
<textarea name=”Info” rows=”9″ cols=”57″ class=”button”><%
=mRs(“Info”) %></textarea>
</td>
</tr>
<tr>
<td height=”25″ align=”center” bgcolor=”#EFEFEF”
width=”118″>回复:</td>
<td height=”100″ rowspan=”2″ bgcolor=”#EFEFEF” width=”640″>
<textarea name=”Reply” rows=”6″ cols=”50″ class=”button”><%
=Reply %></textarea>
</td>
</tr>
<tr>
<td height=”70″ bgcolor=”#EFEFEF” width=”118″></td>
</tr>
<tr>
澳门新葡亰手机版,<td height=”20″ colspan=”2″ align=”center” bgcolor=”#EFEFEF”>
<input name=”Submit1″ type=”submit” id=”Submit” value=” 回复留言 ”
class=”button”>
<input name=”reSet” type=”reSet” id=”reSet4″ value=” 重新输入 ”
class=”button”>
</td>
</tr>
</form>
</table>


‘ 字段名.

/tdtd height=”2″ width=”131″ div align=”center”
%field_type=rs(i).typeselect case field_typecase adEmptytyp =
“Empty”case adTinyInttyp = “TinyInt”case adSmallInttyp = “SmallInt”case
adIntegertyp = “Integer”case adBigInttyp = “BigInt”case
adUnsignedTinyInttyp = “UnsignedTinyInt”case adUnsignedSmallInttyp =
“UnsignedSmallInt”case adUnsignedInttyp = “UnsignedInt”case
adUnsignedBigInttyp = “UnsignedBigInt”case adSingletyp = “Single”case
adDoubletyp = “Double”case adCurrencytyp = “Currency”case adDecimaltyp =
“Decimal”case adNumerictyp = “Numeric”case adBooleantyp = “Boolean”case
adErrortyp = “Error”case adUserDefinedtyp = “UserDefined”case
adVarianttyp = “Variant”case adIDispatchtyp = “IDispatch”case
adIUnknowntyp = “IUnknown”case adGUIDtyp = “GUID”case adDATEtyp =
“DATE”case adDBDatetyp = “DBDate”case adDBTimetyp = “DBTime”case
adDBTimeStamptyp = “DBTimeStamp”case adBStrtyp = “BStr”case adChartyp =
“Char”case adVarChartyp = “VarChar”case adLongVarChartyp =
“LongVarChar”case adWChartyp = “WChar”case adVarWChartyp =
“VarWChar”case adLongVarWChartyp = “LongVarWChar”case adBinarytyp =
“Binary”case adVarBinarytyp = “VarBinary”case adLongVarBinarytyp =
“LongVarBinary”case adChaptertyp = “Chapter”case adPropVarianttyp =
“PropVariant”case elsetyp =
“Unknown”—————————————————————————————————————-

end selectresponse.write typ%’ 字段类型. /div/tdtd height=”2″
width=”105″ div align=”center”%=rs(i).definedsize%/div/td’ 字段长度.td
height=”2″ width=”69″ div align=”center” %attrib=rs(i).attributesif
(attrib and adFldIsNullable)=0 thenresponse.write “No”elseresponse.write
“Yes”end if%/div/td