asp Db browser For access (asp access browser)asp版access數據庫瀏覽器

asp Db browser For access (asp access browser)asp版access數據庫瀏覽器

 

<%
 on error resume next
 title = "asp Db browser For access"
%><!doctype html>
<html lang="zh-CN">
<head>
<meta charset="gb2312" />
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title><%=title%></title>
<meta name="author" content="yujianyue, [email protected]">
<meta name="copyright" content="www.12391.net">
<style>
*{margin:0; padding:0; font-size:12px;}
h1{ font-size:18px;}
a{padding:2px 3px;color:blue;line-height:150%;text-decoration:none;}
a:hover{border:0;background-color:#0180CF;color:white;}
b{padding:5px 10px;background-color:#0180CF;color:white;}
select{width:99%;line-height:150%;}
table{margin:5px auto;border-left:1px solid #a2c6d3;border-top:3px solid #0180CF;width:96vw;}
table td{border-right:1px solid #a2c6d3;border-bottom:1px solid #a2c6d3;}
table td{padding:5px;word-wrap:break-word;word-break:break-all;}
.tt{background:#e5f2fa;line-height:150%;font-size:14px;padding:5px 9px;}
</style>
</head>
<body>
<%

'asp.access.browser V20191215

'功能:列出網站目錄下的access數據並瀏覽:
'1. 遍歷文件夾下所有.mdb,.asa文件供選並記憶;
'2. 然後該數據文件下所有表供選並記憶;
'3. 列出該表下所有字段及內容,並分頁;
'由於不保證每個數據都有唯一不重複字段,暫無表的增改刪計劃
'未設密碼,推薦文件夾下更名爲任意文件名使用以保障數據安全

'問題反饋:15058593138 (同微信號)
'或發郵件:[email protected]

'另外可能後續開發
'php access;php mysql;php csv;asp access;asp excel
'等版本,敬請關注

 dbcokie = Request.Cookies("dbname")
 dbbiaos = Request.Cookies("dbbiao")
 dbsname = request("db")
 rewname = request("tb")

if IsFile(dbsname)=True then

else
if IsFile(dbcokie)=True then
 dbsname = dbcokie
else
 dbsname = "down_zip.asa"
end if
end if

Function ShowFold(filepath)
Set fsoaaaa = Server.CreateObject("Scripting.FileSystemObject")
Set fileobj = fsoaaaa.GetFolder(server.mappath(filepath))
Set fsofolders = fileobj.SubFolders
For Each folder in fsofolders
foldername=folder.name
filepathes=filepath&""&foldername&"/"
ShowFold = ShowFold & ShowFold(filepathes)
Next
ShowFold = ShowFold & ShowFile(filepath)
End Function

Function ShowFile(filepath)
Set fsoeeee = Server.CreateObject("Scripting.FileSystemObject")
Set fileobj = fsoeeee.GetFolder(server.mappath(filepath))
Set fsofile = fileobj.Files
For Each file in fsofile 
filed = ""&filepath&""&file.name&""
if instr(file.name&"@",".mdb@")>0 or instr(file.name&"@",".asa@")>0 then
if filed = dbsname then
Response.Cookies("dbname")=dbsname
Response.Cookies("dbname").Expires=(now()+7) 
ShowFile = ShowFile& "<option value="""&filed&""" selected>"&filed&"</option>"&vbcrlf
else
ShowFile = ShowFile& "<option value="""&filed&""">"&filed&"</option>"&vbcrlf
end if
end if
Next
End Function

Function IsFile(FilePath)
 Set Fso=Server.CreateObject("Scri"&"pting.File"&"Sys"&"temObject")
 If (Fso.FileExists(Server.MapPath(FilePath))) Then
 IsFile=True
 Else
 IsFile=False
 End If
 Set Fso=Nothing
End Function

Function tabar(tabatxt)
tabar = "<table cellspacing=""0"" cellpadding=""0""><tr><td>"&tabatxt&"</td></tr></table>"
End Function

Function getpage(currentpage,totalpage) 
if currentpage mod 10 = 0 then 
Sp = currentpage \ 10 
else 
Sp = currentpage \ 10 + 1 
end if 
Pagestart = (Sp-1)*10+1 
Pageend = Sp*10 
strSplit = "<a href=""?p=1"&thekeys&""" title=""第1頁"">第1頁</a>" &vbcrlf
if Sp > 1 then strSplit = strSplit & "<a href=""?p="&Pagestart-10&""&thekeys&""">前10頁</a>" &vbcrlf
for j=PageStart to Pageend 
if j > totalpage then exit for 
if "_"&j = "_"&currentpage then 
strSplit = strSplit & "<font color=""red"">第"&j&"頁</font>" &vbcrlf
else 
strSplit = strSplit & "<a href=""?p="&j&""&thekeys&""" title=""第"&j&"頁"">第"&j&"頁</a>" &vbcrlf
end if 
next 
if Sp*10 < totalpage then strSplit = strSplit & "<a href=""?p="&Pagestart+10&""&thekeys&""">後10頁</a>" &vbcrlf
strSplit = strSplit & "<a href=""?p="&totalpage&""&thekeys&""">最後1頁</a>" &vbcrlf
strSplit = strSplit & "<!---"&currentpage&":"&totalpage&"--->" &vbcrlf
getpage = strSplit 
End Function


response.write "<div style=""margin:0 auto;overflow:auto;width:99%;height:95vh;"">"

response.write "<table cellspacing=""0"" cellpadding=""0""><tr>"
response.write "<td width=""100"">選擇數據庫:<br>"&vbcrlf
response.write "<select onchange=""window.location='?db='+this.value;"" />"&vbcrlf
 lister = ShowFold("/")
if len(lister)>10 then
response.write lister
else
response.write "<option value="""">無access數據文件</option>"&vbcrlf
end if
response.write "</select>"&vbcrlf
response.write "</td></tr></table>"&vbcrlf

if IsFile(dbsname)=True then
else
response.write tabar("暫未選擇數據"&dbsname)
response.End()
end if
set conn=Server.CreateObject("ADODB.Connection")
conn.open "DRIVER=Driver do Microsoft Access (*.mdb);UID=admin;PWD=;DBQ="&Server.MapPath(dbsname)
If Err Then
err.Clear
response.write tabar("數據異常無法讀取"&dbsname)
response.End()
End If

'列出所有表
Const adSchemaTables = 20
set objSchema = Conn.OpenSchema(adSchemaTables)
ia = 0
rows = "-"
Do While Not objSchema.EOF
	if objSchema("TABLE_TYPE") = "TABLE" then
ia = ia+1
rowname = objSchema("TABLE_NAME")
rows = rows&rowname&"-"
if rowname = rewname then
 rawhtml = rawhtml & "<option value="""&rowname&""" selected>"&rowname&"</option>"&vbcrlf
else
 rawhtml = rawhtml & "<option value="""&rowname&""" >"&rowname&"</option>"&vbcrlf
end if
end if
objSchema.MoveNext
Loop
if len(rewname)<1 then rewname = rowname
if ia < 1 then
 rawhtml = "<option value="""" selected>暫未發現數據表</option>"
end if
 rawhtml = "<select onchange=""window.location='?db="&dbsname&"&tb='+this.value;"" />"&rawhtml&"</select>"
objSchema.Close
set objSchema = nothing

response.write "<table cellspacing=""0"" cellpadding=""0"">"&vbcrlf
response.write "<tr><td>"&rawhtml&"</td></tr>"&vbcrlf
response.write "</table>"&vbcrlf

page=request("p")
if isnumeric(page)=false or len(page)=0 then
page="1"
end if
thekeys = "&db="&dbsname&"&tb="&rewname&""
if instr(rows,"-"&rewname&"-")>0 then
else
rewname = Request.Cookies("dbbiao")
if instr(rows,"-"&rewname&"-")<1 then
response.write tabar("請合理選擇數據表哦"&rows)
response.End()
end if
end if

Response.Cookies("dbbiao")=rewname
Response.Cookies("dbbiao").Expires=(now()+7) 

Response.Write "<table cellspacing=""0"">"&vbcrlf
Response.Write "<caption align='center'>"&rewname&"表</caption>"&vbcrlf
set rsdo=Server.CreateObject("ADODB.RecordSet")
sqldo="select * from ["&rewname&"] "
rsdo.open sqldo,conn,1,1
rsdo.PageSize=10
lies = rsdo.fields.count
 tnames="---"
 response.write "<tr class=""tt"">"&vbcrlf
 for i = 0 to lies - 1 '循環字段名
 lieti = rsdo.fields.item(i).name
 response.write "<td><nobr>" & lieti & "</nobr></td>"&vbcrlf
 tnames=tnames&lieti&"---"
 next
 response.write "</tr>"&vbcrlf

If not (rsdo.bof and rsdo.eof) then
 rsdo.AbsolutePage=page
 for k=1 to rsdo.PageSize
 response.write "<tr>"&vbcrlf
 for i = 0 to lies - 1
 curValue = rsdo.fields.item(i).value
 If IsNull(curValue) or len(curValue)<1 Then
 curValue="&nbsp;"
 End If
 response.write "<td>" & curValue & "</td>"&vbcrlf
 next
 response.write "</tr>"&vbcrlf

 rsdo.movenext
 If rsdo.EOF Then Exit For
 next

rc=rsdo.RecordCount
ps=rsdo.PageSize
pc=rsdo.PageCount
if pc>1 then
response.write "<tr><td colspan="""&lies&""" class=""titi"">"
response.write getPage(page,pc)
response.write "</td></tr>"
end if
rsdo.close
set rsdo=nothing

else
response.write "<tr><td colspan="""&lies&""">"
response.write "<p>暫沒查詢信息!</p>"
response.write "</td></tr>"
end if
Response.Write "</table>"&vbcrlf
%></body>
</html>


asp.access.browser V20191215

功能:列出網站目錄下的access數據並瀏覽:
1. 遍歷文件夾下所有.mdb,.asa文件供選並記憶;
2. 然後該數據文件下所有表供選並記憶;
3. 列出該表下所有字段及內容,並分頁;
由於不保證每個數據都有唯一不重複字段,暫無表的增改刪計劃
未設密碼,推薦文件夾下更名爲任意文件名使用以保障數據安全

問題反饋:15058593138 (同微信號)
或發郵件:[email protected]

另外可能後續開發
php access;php mysql;php csv;asp access;asp excel
等版本,敬請關注

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章