首页 > 编程 > ASP > 正文

如何用Asp取得数据库中所有表名和字段名_ASP教程

2024-05-04 11:04:20
字体:
来源:转载
供稿:网友

推荐:Asp读取文本文件并显示
html head http-equiv=Content-Type content=text/html; charset=gb2312 title/title /head body % LANGUAGE = VBScript % % Const ForReading = 1, ForWriting = 2, ForAppending = 8 Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse

< %
set rs=server.CreateObject("adodb.recordset")
db="db.mdb"
'只要直接更改数据库名称就能够看到效果了。
set conn=server.CreateObject("adodb.connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(db)
conn.open connstr

Set rs=Conn.OpenSchema(20)
Do Until rs.EOF

If rs(3)="TABLE" Then
response.write "表名:"&rs(2)&"<br />"
Set rs1=server.CreateObject("adodb.recordset")
sql="select * from "&rs(2)
Set rs1=conn.execute(sql)
response.write "字段名:"
For i=0 To rs1.fields.count-1
response.write rs1.fields(i).name&" "
Next
response.write "<br />"

Do While Not rs1.eof
response.write " "
For i=0 To rs1.fields.count-1
t=rs1.fields(i).name
response.write rs1(t)&" "
Next
response.write " "
rs1.movenext
Loop
response.write " "
End If

rs.MoveNext
Loop

Set rs=Nothing
Set conn=nothing
% >

 

分享:asp怎样利用InstrRev()获取文件名
InstrRev函数,从字符串的最后一个搜索起,前面字符串。 % Dim strTXT,pos strTXT=www.webjx.com pos=instrRev(strTXT,.) Response.Write pos % 我们搜索的起始是倒序,从com前的一个点。起始的字符的长度,含此点,共十个字符,返回的结果将是9。 通过

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表