繁体中文
设为首页
加入收藏
当前位置:ASP技术首页 >> ASP基础 >> 打开任意数据表并显示表结构及内容

打开任意数据表并显示表结构及内容

2006-09-15 08:00:00  作者:  来源:互联网  浏览次数:0  文字大小:【】【】【
简介:  '函数名:OpOtherDB '作 用:打开任意数据表并显示表结构及内容 '参 数:DBtheStr ---- 要打开表的数据库链接字串 '参 数:Opentdname ---- 要打开表名 '返回值:显示表结构及内容 '******************...

  '函数名:OpOtherDB

'作 用:打开任意数据表并显示表结构及内容

'参 数:DBtheStr ---- 要打开表的数据库链接字串

'参 数:Opentdname ---- 要打开表名

'返回值:显示表结构及内容

'**************************************************

Public Function OpOtherDB(ByVal DBtheStr,ByVal Opentdname)

Response.write "

" & vbCrlf

Set Opdb_Conn=server.createobject("ADODB.Connection")

Set Opdb_Rs =server.createobject("ADODB.Recordset")

Opdb_Conn.open DBtheStr

Opdb_sql_str="select * from "&Opentdname

Opdb_Rs.open Opdb_Sql_Str,Opdb_Conn,1,1

Nfieldnumber=Opdb_Rs.Fields.count

If Nfieldnumber >0 then

Response.write "" & vbCrlf

For i=0 to (Nfieldnumber-1)

Response.write ""

Response.write Trim(Opdb_Rs.Fields(i).Name)

Response.write "" & vbCrlf

Next

temptbi=0

Do While Not Opdb_Rs.Eof

Response.write "" & vbCrlf

For i=0 to (Nfieldnumber-1)

If (temptbi<2) Then

Response.write ""

Response.write Trim(Opdb_Rs.Fields(i))

Response.write "" & vbCrlf

temptbi=temptbi+1

Else

Response.write ""

Response.write Trim(Opdb_Rs.Fields(i))

Response.write "" & vbCrlf

If temptbi>=3 Then

temptbi=0

Else

temptbi=temptbi+1

End If

End If

Next

Opdb_Rs.MoveNext

Response.write "" & vbCrlf

Loop

End If

Opdb_Rs.Close

Opdb_Conn.Close

Set Opdb_Rs = Nothing

Set Opdb_Conn=Nothing

Response.write "

" & vbCrlf

End function

责任编辑:admin
相关文章