如何执行数据库里的ASP代码(HTML生成问题)

来源:百度知道 编辑:UC知道 时间:2024/05/14 19:00:02
<%
Dim ConnStr
ConnStr = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath("2.mdb")
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open ConnStr

OutHTML = GetLables(LoadFile("templates/index.htm"))
'OutHTML就是将要生成HTML字符串,以下的函数都是调用。

conn.close
Set conn = nothing

'LoadFile 函数是读取模板
Function LoadFile(ByVal Files)
Dim objStream,objFSO,FSO,TmpFSO
On Error Resume Next
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
If Err.Number<>0 Then
Response.Write "<Script>alert('提示\n\n非常遗憾,您的主机不支持FSO!');history.go(-1);</Script>"
Err.Clear
Response.End
Else
If objFSO.FileExists(Server.MapPath(Files)) Then
Set FSO = objFSO.OpenTextFile(Server.MapPath(Files),1,False)
LoadFile = FSO.Readall()

Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open ConnStr
Template = LoadFile("demo.html")
Template = Replace_DB_HTML_Labels(Template)
Template = Replace_DB_ASP_Labels(Template)
Template = Replace_Page_ASP_Labels(Template)
Response.write Template
conn.close
Set conn = nothing
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Function Get_Labels_Content(lable_code)
Dim TempStr
Set rs = Server.CreateObject("ADODB.RecordSet")
sql = "SELECT top 1 [Content] FROM [Tags] WHERE [alies]='" & lable_code & "'"
rs.Open sql,conn, 1,1
If Not rs.EOF Then
TempStr = rs("Content")
End If
rs.Close
Set rs = Nothing
Get_Labels_Content = TempStr
End Function
'^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Functio