还是上次向你请教的ASP转html的问题 我的asp代码如下,帮忙给我转一下,谢啦
<%@LANGUAGE="VBSCRIPT"CODEPAGE="65001"%><!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transi...
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "e:/1.mdb"
set rs=Server.CreateObject("ADODB.recordset")
sql="Select * from ban"
rs.Open sql, conn
%>
<table border="1" width="100%">
<tr>
<%for each x in rs.Fields
response.write("<th>" & x.name & "</th>")
next%>
</tr>
<%do until rs.EOF%>
<tr>
<%for each x in rs.Fields%>
<td><%Response.Write(x.value)%></td>
<%next
rs.MoveNext%>
</tr>
<%loop
rs.close
conn.close
%>
</table>
</body>
</html> 展开
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>
<body>
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open "e:/1.mdb"
set rs=Server.CreateObject("ADODB.recordset")
sql="Select * from ban"
rs.Open sql, conn
%>
<table border="1" width="100%">
<tr>
<%for each x in rs.Fields
response.write("<th>" & x.name & "</th>")
next%>
</tr>
<%do until rs.EOF%>
<tr>
<%for each x in rs.Fields%>
<td><%Response.Write(x.value)%></td>
<%next
rs.MoveNext%>
</tr>
<%loop
rs.close
conn.close
%>
</table>
</body>
</html> 展开
2个回答
展开全部
<%
Private Function bytes2BSTR(vIn)
Dim i, ThischrCode, NextchrCodea
strReturn = ""
For i = 1 To LenB(vIn)
ThischrCode = AscB(MidB(vIn, i, 1))
If ThischrCode < &H80 Then
strReturn = strReturn & Chr(ThischrCode)
Else
NextchrCode = AscB(MidB(vIn, i + 1, 1))
strReturn = strReturn & Chr(CLng(ThischrCode) * &H100 + CInt(NextchrCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function
Function GetURL(url)
Set Retrieval = Server.CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "GET", url, False, "", ""
.Send
GetURL = .ResponseText
GetURL = bytes2BSTR(.Responsebody)
End With
Set Retrieval = Nothing
End Function
body = GetURL("http://文件名") ' 动态页面地址
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Dim checkfile
checkfile=server.mappath("index.htm") ' 需要生成的静态页面的全路径文件名
if (fs.FileExists(checkfile)) then
Dim df
Set df=fs.GetFile(checkfile)
df.delete
end if
set ts = fs.createtextfile(checkfile,true)
ts.write body
ts.close
set fs=nothing
url="index.htm"
Response.Redirect(url)
%>
Private Function bytes2BSTR(vIn)
Dim i, ThischrCode, NextchrCodea
strReturn = ""
For i = 1 To LenB(vIn)
ThischrCode = AscB(MidB(vIn, i, 1))
If ThischrCode < &H80 Then
strReturn = strReturn & Chr(ThischrCode)
Else
NextchrCode = AscB(MidB(vIn, i + 1, 1))
strReturn = strReturn & Chr(CLng(ThischrCode) * &H100 + CInt(NextchrCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function
Function GetURL(url)
Set Retrieval = Server.CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "GET", url, False, "", ""
.Send
GetURL = .ResponseText
GetURL = bytes2BSTR(.Responsebody)
End With
Set Retrieval = Nothing
End Function
body = GetURL("http://文件名") ' 动态页面地址
Set fs=Server.CreateObject("Scripting.FileSystemObject")
Dim checkfile
checkfile=server.mappath("index.htm") ' 需要生成的静态页面的全路径文件名
if (fs.FileExists(checkfile)) then
Dim df
Set df=fs.GetFile(checkfile)
df.delete
end if
set ts = fs.createtextfile(checkfile,true)
ts.write body
ts.close
set fs=nothing
url="index.htm"
Response.Redirect(url)
%>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询