asp 中 我 要查询一个表的字段的名称 和标题 access数据库,并进行输出,最高给个简单的源码。。
2个回答
展开全部
<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>
------------------------------------------------
上面的代码中,只要我们知道缺御了表名,那么表中的字段名就无须知道也可以显示所有数据。整个这一段代码可以封装成一个函数来用(函数变量为数据表名)
<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>
------------------------------------------------
上面的代码中,只要我们知道缺御了表名,那么表中的字段名就无须知道也可以显示所有数据。整个这一段代码可以封装成一个函数来用(函数变量为数据表名)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询