【正文】
/TABLEHR ‘將所有留言內(nèi)容寫至WEB頁(yè)面 Tab End Sub % /body/html76 / 76。 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主 頁(yè) : A HREF= amp。 rs(Email) amp。 rs(Email) amp。 /TD ‘為電子郵件地址加上超級(jí)連接 Tab = Tab amp。 TRTD姓 名 : amp。 amp。 (Page+1) amp。 (Page1) amp。 ) ’執(zhí)行SQL語句 sql ’自動(dòng)轉(zhuǎn)至查看留言薄頁(yè)面 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= % ’分頁(yè)顯示之子程序 Sub ShowOnePage( rs, Page ) ’rs為數(shù)據(jù)庫(kù)記錄對(duì)象, Page為頁(yè)數(shù) = Page ’AbsolutePage屬性將當(dāng)前數(shù)據(jù)記錄移到第Page頁(yè)的第一條 For iPage = 1 To ‘PageSize為每頁(yè)的數(shù)據(jù)條數(shù) Rstogbook rs ‘調(diào)用處理顯示內(nèi)容之子程序 ‘將當(dāng)前數(shù)據(jù)記錄移至下一條 If Then Exit For ’如果顯示頁(yè)碼為最后一頁(yè),則要判斷是否移至數(shù)據(jù)記錄未 Next End Sub ‘打開或直接得到數(shù)據(jù)庫(kù)連接對(duì)象Connection之子程序 Function OpenOrGet_Database(SessionName) ‘SessionName為公用對(duì)象中的名稱 Dim conn ‘如果數(shù)據(jù)庫(kù)連接對(duì)象未打開則創(chuàng)建此對(duì)象并打開 If Not IsObject(Session(SessionName)) ThenSet conn = () guestbook,Set Session(SessionName) = conn’將打開的數(shù)據(jù)庫(kù)連接對(duì)象存入公用對(duì)象Session中 End If ’直接從公用對(duì)象SessionnName中取出已打開的數(shù)據(jù)庫(kù)連接對(duì)象 Set OpenOrGet_Database = Session(SessionName) End Function ‘直接打開數(shù)據(jù)庫(kù)連接對(duì)象Connection之子程序 Function Open_Database(SessionName ) Dim conn Set conn = () guestbook, Set Session(SessionName) = conn Set Open_Database = Session(SessionName) End Function ‘打開或直接得到數(shù)據(jù)庫(kù)記錄對(duì)象Recordset之子程序 Function OpenOrGet_RsAndPageSize( conn, sql, SessionName, PageSize ) ‘conn為數(shù)據(jù)庫(kù)連接對(duì)象,sql為SQL語句, SessionName為公用對(duì)象名稱, PageSize為每頁(yè)顯示記錄條數(shù) Dim rs ‘如果數(shù)據(jù)庫(kù)記錄對(duì)象未打開則創(chuàng)建此對(duì)象并打開 If Not IsObject(Session(SessionName)) ThenSet rs = () sql, conn, adOpenStatic‘,意為當(dāng)前數(shù)據(jù)記錄可自由移動(dòng) Set Session(SessionName) = rs ’將打開的數(shù)據(jù)庫(kù)記錄對(duì)象存入公用對(duì)象Session中 = PageSize ‘記錄每頁(yè)顯示的數(shù)據(jù)條數(shù) End If ’直接從公用對(duì)象SessionName中得到已經(jīng)打開的數(shù)據(jù)庫(kù)記錄對(duì)象 Set OpenOrGet_RsAndPageSize = Session(SessionName) End Function ‘直接打開數(shù)據(jù)記錄對(duì)象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對(duì)象 Set conn = () ’打開ODBC數(shù)據(jù)源guestbook guestbook, ’對(duì)信息按數(shù)據(jù)庫(kù)中字段定義長(zhǎng)度進(jìn)行處理,因插入數(shù)據(jù)時(shí)其值不能為空,故由空格表示 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ù)庫(kù)中 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ù)庫(kù)》棗人民郵電出版社《Active Server Pages 編程指南》棗宇航出版社《Frontpage 98實(shí)用指南》棗清華大學(xué)出版社《SQL Server數(shù)據(jù)庫(kù)應(yīng)用開發(fā)技術(shù)》棗人民郵電出