<%@LANGUAGE="VBScript" %> <% Option Explicit Response.buffer=True response.Expires=-1500 '------------------If your site is hosted by another site then change your path in the DBQ value below i.e. in place of Server.MapPath("/SmartGuestBook/SmartGuestbook.mdb") type in Server.MapPath("/Your_site_path/SmartGuestBook/SmartGuestbook.mdb")----------------- strDB = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("/SmartGuestBook/SmartGuestbook.mdb") & ";DefaultDir=" & Server.MapPath(".") & ";DriverId=25;FIL=MS Access;MaxBufferSize=512;PageTimeout=5" '------------------End of Database connection string ----------------- Dim DBConn,strDB,rsGuestBook,x,id,intSize,strSelectSQL,strInsertSQL,strDate,strName,strEmail,strMess,blnSubmit dim fldName,fldEmail,fldMess,fldDate,intPage,intStart,intFinish,intCount,intPageCount,intRecord,intNav intNav=request.QueryString("NAV") if intNav = "" then intPage = 1 else intPage = cint(intNav) end if strName=request("name") strEmail=request("email") strMess=request("mess") strDate=CDate(Date) intSize=cint(request.querystring("size")) blnSubmit=request.querystring("submit") id=request.querystring("id") strInsertSQL="insp_guestbook '" & strDate & "','" & strName & "','" & strEmail & "','" & strMess & "'" strSelectSQL="exec selsp_guestbook" Set DBConn = Server.CreateObject("ADODB.Connection") DBConn.Open strDB if request("action")="new" then DBConn.execute strInsertSQL DBConn.Close Set DBConn = nothing response.write "success=1" response.flush else set rsGuestBook=Server.CreateObject("ADODB.Recordset") rsGuestBook.ActiveConnection = DBConn rsGuestBook.Source = strSelectSQL rsGuestBook.CursorType = 3 rsGuestBook.CursorLocation = 3 rsGuestBook.LockType = 1 rsGuestBook.Open rsGuestBook.PageSize = intSize rsGuestBook.CacheSize = rsGuestBook.PageSize intPageCount = rsGuestBook.PageCount intCount = rsGuestBook.RecordCount Set rsGuestBook.ActiveConnection = Nothing If (not rsGuestBook.EOF) then rsGuestBook.AbsolutePage = intPage intStart = rsGuestBook.AbsolutePosition End if if CInt(intPage) = CInt(intPageCount) then intFinish = intCount else intFinish = intStart + (rsGuestBook.PageSize - 1) end if response.write "count=" & intCount if intCount=0 then response.write "&f_name=No Guest Entries Yet" if not rsGuestBook.Eof then if blnSubmit="True" then rsGuestBook.Movenext if not rsGuestBook.Eof then set fldName=rsGuestBook("fldName") set fldEmail=rsGuestBook("fldEmail") set fldMess=rsGuestBook("fldMessage") response.write "&f_name=" & fldName & "&f_email=" & fldEmail & "&f_mess=" & fldMess & "&f_date=" & DisplayDate(rsGuestBook("fldDate")) & "&date=" & DisplayDate(strDate) response.flush end if end if x = (intNav-1)*intSize+1 For intRecord = 1 to rsGuestBook.PageSize if rsGuestbook.EOF then Exit For strDate=rsGuestBook("fldDate") response.write "&name" & x & "=" & fldName & "&email" & x & "=" & fldEmail & "&mess" & x & "=" & fldMess & "&date" & x & "=" & DisplayDate(strDate) x = x + 1 response.flush rsGuestBook.Movenext Next rsGuestBook.Close Set rsGuestBook = nothing set fldName=nothing set fldEmail=nothing set fldMess=nothing DBConn.Close Set DBConn = nothing end if function DisplayDate(strEntryDate) strEntryDate=FormatDateTime(CDate(strEntryDate),1) strEntryDate=trim(right(strEntryDate,len(strEntryDate)-Instr(strEntryDate,","))) strEntryDate=left(strEntryDate,3) & right(strEntryDate,len(strEntryDate)-Instr(strEntryDate," ")) DisplayDate=strEntryDate end function %>