asp 中 我 要查询一个表的字段的名称 和标题 access数据库,并进行输出,最高给个简单的源码。。

如题所述

<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#006699">
<tr>
<%
MM_SQLString = "Select * From table_name"
Set MM_Recordset = getRecordSet(MM_SQLString)
For I = 0 To MM_Recordset.Fields.Count-1
Response.Write("<td>" &MM_Recordset.Fields(I).name & "</td>")
Next
%>
</tr>
<%
Do while not MM_Recordset.Eof
Response.Write("<tr>")
For X=0 To MM_Recordset.Fields.Count-1
Response.Write("<td>" & MM_Recordset.Fields(MM_Recordset.Fields(X).name).Value & "</td>")
Next
Response.Write("</tr>")
MM_Recordset.Movenext
Loop
ReleaseRecordset(MM_Recordset)
%>
</table>
------------------------------------------------
上面的代码中,只要我们知道了表名,那么表中的字段名就无须知道也可以显示所有数据。整个这一段代码可以封装成一个函数来用(函数变量为数据表名)
温馨提示:答案为网友推荐,仅供参考
第1个回答  2011-09-18
name).Value & "</td>")
Next
Response.Write