【正文】
/TABLEHR ‘將所有留言內(nèi)容寫至WEB頁面 Tab End Sub % /body/html。 rs(Time) amp。 /FONT/PRE/TD/TR Tab = Tab amp。 TRTD COLSPAN=3 BGCOLOR=00FFFFPREFONT Size=+1 Tab = Tab amp。 TRTD留 言 : amp。 rs(City) amp。 /TD Tab = Tab amp。 TD省 份 : amp。 rs(Country) amp。 /A/TD/TR Tab = Tab amp。 Tab = Tab amp。 TRTD COLSPAN=3主 頁 : A HREF= amp。 rs(Email) amp。 rs(Email) amp。 /TD ‘為電子郵件地址加上超級連接 Tab = Tab amp。 TRTD姓 名 : amp。 amp。 (Page+1) amp。 (Page1) amp。 ) ’執(zhí)行SQL語句 sql ’自動轉(zhuǎn)至查看留言薄頁面 end if % htmlheadtitle留言處理/title /headbody background= p/p ’ 如果姓名和內(nèi)容為空,給出提示信息 p align=center big font color=FF0000 face=仿宋_GB2312strong姓名和留言必須輸入!/strong/font/big/p p align=centerstrongfont face=隸書a href=返 回/a/font/strong/p /body /html ’ !include file= % ’分頁顯示之子程序 Sub ShowOnePage( rs, Page ) ’rs為數(shù)據(jù)庫記錄對象, Page為頁數(shù) = Page ’AbsolutePage屬性將當前數(shù)據(jù)記錄移到第Page頁的第一條 For iPage = 1 To ‘PageSize為每頁的數(shù)據(jù)條數(shù) Rstogbook rs ‘調(diào)用處理顯示內(nèi)容之子程序 ‘將當前數(shù)據(jù)記錄移至下一條 If Then Exit For ’如果顯示頁碼為最后一頁,則要判斷是否移至數(shù)據(jù)記錄未 Next End Sub ‘打開或直接得到數(shù)據(jù)庫連接對象Connection之子程序 Function OpenOrGet_Database(SessionName) ‘SessionName為公用對象中的名稱 Dim conn ‘如果數(shù)據(jù)庫連接對象未打開則創(chuàng)建此對象并打開 If Not IsObject(Session(SessionName)) ThenSet conn = () guestbook,Set Session(SessionName) = conn’將打開的數(shù)據(jù)庫連接對象存入公用對象Session中 End If ’直接從公用對象SessionnName中取出已打開的數(shù)據(jù)庫連接對象 Set OpenOrGet_Database = Session(SessionName) End Function ‘直接打開數(shù)據(jù)庫連接對象Connection之子程序 Function Open_Database(SessionName ) Dim conn Set conn = () guestbook, Set Session(SessionName) = conn Set Open_Database = Session(SessionName) End Function ‘打開或直接得到數(shù)據(jù)庫記錄對象Recordset之子程序 Function OpenOrGet_RsAndPageSize( conn, sql, SessionName, PageSize ) ‘conn為數(shù)據(jù)庫連接對象,sql為SQL語句, SessionName為公用對象名稱, PageSize為每頁顯示記錄條數(shù) Dim rs ‘如果數(shù)據(jù)庫記錄對象未打開則創(chuàng)建此對象并打開 If Not IsObject(Session(SessionName)) ThenSet rs = () sql, conn, adOpenStatic‘,意為當前數(shù)據(jù)記錄可自由移動 Set Session(SessionName) = rs ’將打開的數(shù)據(jù)庫記錄對象存入公用對象Session中 = PageSize ‘記錄每頁顯示的數(shù)據(jù)條數(shù) End If ’直接從公用對象SessionName中得到已經(jīng)打開的數(shù)據(jù)庫記錄對象 Set OpenOrGet_RsAndPageSize = Session(SessionName) End Function ‘直接打開數(shù)據(jù)記錄對象Recordset之子程序 Function Open_RsAndPageSize( conn, sql, SessionName, PageSize ) Dim rs Set rs = () sql, conn, adOpenStatic Set Session(SessionName) = rs = PageSize Set Open_RsAndPageSize = Session(SessionName) End Function % htmlheadmeta equiv=ContentType content=text/html。 , sql = sql amp。 , sql = sql amp。 , sql = sql amp。 , sql = sql amp。 , sql = sql amp。 , sql = sql amp。 End Function ’ Name = Request(Name) Email = Request(Email) Url = Request(Url) Country = Request(Country) State = Request(State) City = Request(City) Comments = Request(Comments) ’ 判斷姓名和內(nèi)容是否為空,否則給出提示信息 If Name And Comments Then ’ 創(chuàng)建ADODB對象 Set conn = () ’打開ODBC數(shù)據(jù)源guestbook guestbook, ’對信息按數(shù)據(jù)庫中字段定義長度進行處理,因插入數(shù)據(jù)時其值不能為空,故由空格表示 Name = Left( Name, 10 ) if = then Email= else Email = Left( Email, 40 ) end if if Url= then Url= else Url = Left( Url, 50 ) end if if Country= then Country= else Country = Left( Country,10) end if if State= then State= else State = Left( State,10) end if if City= then City= else City = Left( City,10) end if ’定義SQL語句,將信息加入數(shù)據(jù)庫中 sql = Insert Into Guestbook (Name, Email, Url, Country,State,City,Comments) Values( sql = sql amp。 ) amp。, 39。 amp。 color: rgb(0,0,255)。 fontweight: boldinput type=reset value=清 除(Reset) name=Reset style=fontfamily: 隸書。 fontsize: 10pt。d like to know what you think about our web site. Please leave your ments in this public guest book so wecan share your thoughts with other visitors./font/strong/p ’留言表單 form method=POST action= ’ pfont face=宋體 color=008040strong 您的名字: input type=text name=Name size=21small(不能空?lt。WEB數(shù)據(jù)庫》棗人民郵電出版社《Active Server Pages 編程指南》棗宇航出版社《Frontpage 98實用指南》棗清華大學出版社《SQL Server數(shù)據(jù)庫應用開發(fā)技術(shù)》棗人民郵電出版社《WI