For CountRecords = 1 to 10
If rs.EOF then Exit for
Daten = rs("Date")
Name = rs("Name")
Email = rs("Email")
Place = rs("Place")
Url = rs("Url")
If Url<>"" and InStr(Url,"http://")=0 then Url="http://"&Url
Comment = rs("Comment")
%>
<table width="600" cellpadding=0 cellspacing=2 border=0>
<tr>
<td width="80" bgcolor="<%= Topcellbg %>"><font size=2 color="<%= Topcelltext %>"><b>日期:</b></font></td>
<td bgcolor="<%= cellbg %>"><font size=2 color="<%= celltext %>"><%= Daten %></font></td></tr>
<tr>
<td width="80" bgcolor="<%= Topcellbg %>"><font size=2 color="<%= Topcelltext %>"><b>名字:</b></font></td>
<td bgcolor="<%= cellbg %>"><font size=2><a href="mailto:<%= Email %>"><%= Name %></font></a></td></tr>
<tr>
<td width="80" bgcolor="<%= Topcellbg %>"><font size=2 color="<%= Topcelltext %>"><B>来自:</b></font></td>
<td bgcolor="<%= cellbg %>"><font size=2 color="<%= celltext %>"><%= Place %></font></td></tr>
<tr>
<td width="80" bgcolor="<%= Topcellbg %>"><font size=2 color="<%= Topcelltext %>"><b>主页:</b></font></td>
<td bgcolor="<%= cellbg %>"><font size=2><a href="<%= Url %>" target="_blank"><%= Url %></font></a></td></tr>
<tr>
<td width="80" bgcolor="<%= Topcellbg %>"><font size=2 color="<%= Topcelltext %>"><B>内容:</b></font></td>
<td bgcolor="<%= cellbg %>"><font size=2 color="<%= celltext %>"><%= Comment %></font></td></tr>
</table><br>
<%
rs.movenext
Next
If Page > 1 Then
%>
<a href="<%= NameOfFile %>?Page=1"><font face="<%= Font %>" size=3><b><<</b></font></a>
<a href="<%= NameOfFile %>?Page=<%= Page - 1 %>"><font face="<%= Font %>" size=3><b><</b></font></a>
<%
End If
If NOT rs.EOF then
%>
<a href="<%= NameOfFile %>?Page=<%= Page + 1 %>"><font face="<%= Font %>" size=3><b>></b></font></a>
<a href="<%= NameOfFile %>?Page=<%= TotalPages %>"><font face="<%= Font %>" size=3><b>>></b></font></a>
<%
End If
End If
conn.close
set conn = nothing
End Sub
If Mode = "Sign" then
If Flag = "" then
'If form has not been submitted, no flag is regongnised
WhatToDo = "Sign Guestbook"
Header
SignPage
Footer
End If
If Flag = 1 then
'If form has been submitted, flag will be set to 1
WhatToDo = "Sign Guestbook"
Header
If Not Validate then
'The "Validate" function writes Error message
Signpage
Else
InsertInfo
Response.write "<font color='" & textcolor & "' face='" & font & "' size=5>"
Response.write "成功!<br><br>"
Response.write "<a href='" & NameOfFile & "'>返回</a><br>"
Response.write "</font>"
Footer
End If
Footer
End If
Else
WhatToDo = "View Guestbook"
Header
Viewpage
Footer
End If
Mode = Request.QueryString("Mode")
Page = Request.QueryString("Page")
ShowTheCode = "yes"
If IsEmpty(Request.QueryString("Page")) then Page = 1
Flag = Request.Form("Flag")
If mode = "Sign" then
Name = Request.Form("Name")
Email = Request.Form("Email")
Place = Request.Form("Place")
Url = Request.Form("Url")
Comment = Request.Form("Comment")
End If
'<<<<<<<<<<<<>>>>>>>>>>>>
Function Validate
Dim ErrorMsg
ErrorMsg = "<ul>"
If Name = "" Then
ErrorMsg = ErrorMsg & "<li>大哥,你没名字呀!</li>"
End if
If Email = "" Then
ErrorMsg = ErrorMsg & "<li>我倒,没有email还来网上混l</li>"
ElseIf InStr(Email, "@") = 0 Then
ErrorMsg = ErrorMsg & "<li>骗我没上网呀,EMAIL起码有个@吧?</li>"
End if
If Comment = "" Then
ErrorMsg = ErrorMsg & "<li>没有留言呀!!!</li>"
ElseIf InStr(Comment, ">") <> 0 or InStr(Comment, "<") <> 0 Then
ErrorMsg = ErrorMsg & "<li>Do not use < or ></li>"
End if
ErrorMsg = ErrorMsg & "</ul>"
If Not ErrorMsg = "<ul></ul>" then
Response.write "<font size=2 color='" & ErrorColor & "' face='" & font & "' size=5>"
Response.write "出错拉!!!!<br></font>"
Response.write "<font size=2 color='" & TextColor & "' face='" & font & "' size=3>"
Response.write ErrorMsg
Response.write "</font><br><br>"
Validate = False
Else
Validate = True
End if
End Function
<%
'数据库连接
dim conn
dim connstr
dim db
'更改数据库名字
db="database/data.mdb"
Set conn = Server.CreateObject("ADODB.Connection")
connstr="driver={Microsoft Access Driver (*.mdb)};dbq="& Server.MapPath(""&db&"")
conn.Open connstr
sub endConnection()
conn.close
set conn=nothing
end sub
'结束
%>
给你个连接ACCESS的例子
<%
on error resume next
dim i
dim str1,str2,strN,strT,strS,strC
Set MyFileObject=Server.CreateObject("Scripting.FileSystemObject")
if not MyFileObject.fileexists(server.mappath("/test.txt")) then
set ContenText=MyFileObject.createtextfile(server.mappath("/test.txt"))
ContenText.close
end if
'````````````````````````````````````````
' 以上程序建立了一个 test.txt 文本文件
'````````````````````````````````````````
set tmptest=MyFileObject.opentextfile(server.mappath("/test.txt"))
Set Myfile=MyFileObject.GetFile(server.mappath("/test.txt"))
if Myfile.size >=262144 then
set tmpfile=MyFileObject.createtextfile(server.mappath("/tmp2.txt"))
for i=1 to 40
str1=tmptest.readline
str2=tmptest.readline
tmpfile.writeline(str1)
tmpfile.writeline(str2)
str1=" "
str2=" "
next
tmptest.close
tmpfile.close
Myfile.close
MyFileObject.copyfile server.mappath("/tmp2.txt"),server.mappath("/test.txt")
MyFileObject.deletefile server.mappath("/tmp2.txt")
end if
'````````````````````````````````````````
'以上程序控制test.txt文本内容的总量
'````````````````````````````````````````
strN=request("name")
strS=request("sex")
strT=now
strC=request("msg")
if strS=empty then strS="帅哥"
set fileTmp=server.createobject("scripting.filesystemobject")
set textTmp=fileTmp.createtextfile(server.mappath("/tmp1.txt"))
Set MyTextFile=fileTmp.opentextfile(Server.MapPath("/test.txt"),1)
textTmp.writeline(strN&" ("&strS &") 留言时间:"& strT)
textTmp.writeline(strC)
textTmp.close
set textTmp1=fileTmp.opentextfile(server.mappath("/tmp1.txt"),8,true)
while not MyTextFile.atendofstream
textTmp1.writeline(MyTextFile.readline)
wend
MyTextFile.close
textTmp1.close
fileTmp.copyfile server.mappath("/tmp1.txt"),server.mappath("/test.txt")
fileTmp.deletefile server.mappath("/tmp1.txt")