|
|
|
Please
Post your comments for the site
|
VIEWERS
COMMENTS |
<%
submit = request("Submit")
name = request("name")
message = request("message")
pageno = request("pageno")
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsGuestbook 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query to query the database
'Create an ADO connection object
Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
adoCon.Open = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("newsandviews.mdb") & ";Persist Security Info=False"
'Initialise the strSQL variable with an SQL statement to query the database
if(submit<>"")then
sql = "Insert into newsandviews (name,message,active_flag) values ( '" & name & "',' " & message & "','No')"
adoCon.execute sql
end if
strSQL = "SELECT count(*) FROM newsandviews where active_flag = 'Yes';"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open strSQL, adoCon
totalRecords = rs(0)
totalPages = int((totalRecords/10)+1)
'response.write totalPages
if(pageno>1) then
topRecords = (pageno-1) * 10
strsql = " SELECT TOP 10 * FROM newsandviews where id NOT IN ( SELECT TOP " & topRecords &" id FROM newsandviews where active_flag = 'Yes' ORDER BY id DESC ) and active_flag = 'Yes' ORDER BY id DESC"
else
strsql = "SELECT TOP 10 * FROM newsandviews where active_flag = 'Yes' ORDER BY id DESC"
end if
'Response.write strsql
'Response.end
'Open the recordset with the SQL query
'Create an ADO recordset object
Set rsGuestbook = Server.CreateObject("ADODB.Recordset")
rsGuestbook.Open strSQL, adoCon
if(pageno < 1)then
i=0
else
i = (pageno-1) * 10
end if
Do While not rsGuestbook.EOF
i = i+1
'Write the HTML to display the current record in the recordset
Response.Write (" ") & i & ". "
Response.Write (rsGuestbook("message"))
Response.Write (" ")
Response.Write "Submitted By: " & (rsGuestbook("name")) & " "
Response.Write (" ...........................................")
'Move to the next record in the recordset
rsGuestbook.MoveNext
Loop'Reset server objects
rsGuestbook.Close
Set rsGuestbook = Nothing
Set adoCon = Nothing
%>
<%
'response.write totalPages
if (totalPages > 1) then
for j=1 to totalPages
%>
<%=j%>
<%
next
end if
%>
|
|
|
|
|
|
|
|