ASP遍历数据库
7 十 2005
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <!--#include file="inc/sql.asp"--> <% Set rstSchema = db.OpenSchema(20) Do Until rstSchema.EOF '遍历数据库表 if rstSchema("TABLE_TYPE")="TABLE" then response.write rstSchema("TABLE_NAME") & ":" set rs=db.execute("select * from " & rstSchema("TABLE_NAME")) for i=0 to rs.fields.count-1 '遍历表中字段 response.write rs(i).name &" " next end if response.write "<br>" rstSchema.MoveNext Loop %> |
2 Responses for "ASP遍历数据库"
-
将第8行,改成:
set rs=db.execute(“select * from ["&rstSchema("TABLE_NAME")&"]“)否则有问题,原因:如果数据库表名有个叫user的保留字段,可能就出错了。
Leave a Reply
2011-11-10 18:11