< % response.charset="gb2312"
tblname=request("tb")
dim objorasession,objoradb
dim strdbuser,strdbpwd,strdbconn
call connectdb()
sub connectdb() 连接数据库
on error resume next
strdbuser = "liujincai" 连接用户名
strdbpwd = "ljc1001" 用户密码
strdbconn = "hp1" 连接字符串
set objorasession = server.createobject("oracleinprocserver.xorasession")
set objoradb = objorasession.opendatabase(strdbconn,strdbuser & "/" & strdbpwd,0)
if err.number>0 then
response.write "错误 :" & err.description & ""
response.end
end if
end sub
sub enddb()
set objoradb = nothing
set objorasession = nothing
end sub
function gettablelist(str)
dim strsql,strtmp
dim objrs
strsql = "select at.table_name as tname,au.username as uname from all_tables at,all_users au where au.username=at.owner order by au.username"
set objrs = objoradb.dbcreatedynaset(strsql,0)
while not objrs.eof
stra = objrs("uname") & "." & objrs("tname")
if str=stra then
strtmp = strtmp & "" & stra & ""
else
strtmp = strtmp & "" & stra & ""
end if
objrs.movenext
wend
set objrs = nothing
gettablelist = strtmp
end function
% >
all tables : < %=gettablelist(tblname)% > (< %=strdbuser & "/" & strdbpwd & "@" & strdbconn% >) |
< %
if tblname<>"" then
strsql = "select * from " & tblname
set rs = objoradb.dbcreatedynaset(strsql,0)
response.write "
"for i=0 to rs.fields.count-1
response.write "
" & rs.fields(i).name & ""next
response.write "
"while not rs.eof
response.write "
"for i=0 to rs.fields.count -1
response.write "
" & rs.fields(i).value & ""next
response.write "
"rs.movenext
wend
set rs = nothing
end if
% >
细节可查询
http://www.jojoo.net/article/list.asp?id=4101
http://www.cx66.com/cxgzs/program/asp/581.htm
http://www.51one.net/info/1797.htm
http://www.kupage.com/webdesign/7/20031017/1641380000027pjtnjgy.htm