Click to See Complete Forum and Search --> : Pagging


petrod
04-08-2004, 01:01 AM
I have this code:
This code can give the names of all rows in the database.But i have managed to put the headings of the tables as i want.
%>
Dim intRec
objRS.PageSize = 5
objRS.CacheSize = 5
objRS.CursorLocation = adUseClient
<TABLE BORDER = 1>
<TR>
<TH>Code</TH>
<TH>Name</TH>
<TH>ADRESS</TH?
</TR>
<%
For intRec=1 To objRS.PageSize
If Not objRS.EOF Then
Response.Write "<tr>"
For Each fldF in objRS.Fields
Response.Write "<td>" & fldF.Value & "</td>"
Next
objRS.MoveNext
End If
Next
Response.Write "</tbody></table><p>"
This code puts the heading i want, but it gives me all the rows from the database. I want to have only 3 rowsn show the one that i will choose as the headings.I want after the for to be able to put my own rows,to choose what rows to put i from the code and not the user.
Tto put my own rows from the databse like the below.How can i merge those two together.
%> <TR>
<TD><%=objRS.Fields("title").Value%></TD>
<TD><%=objRS.Fields("capcity").Value%></TD>
<TD><%=objRS.Fields("airline").Value%></TD>
</TR><%

simflex
04-08-2004, 01:57 PM
If I understand you correctly, you want to be able to select and display only the records you want so you can format the look and feel the way you want it, right.

Then this is all you need:


<%

dim strsql,rs

set my_conn= Server.CreateObject("ADODB.Connection")

myDSN="DSN=yourDSN"

'response.write mydsn
'response.end

my_Conn.Open myDSN
strsql= "SELECT * from yourTable 'You can also just select specific records like: select column1, column2, column3
set rs = my_conn.Execute (StrSql)

'response.write("strsql")
'response.end

if rs.BOF or rs.EOF then ' No records found

response.write "Hmm... That didn't work.<br>There was an error. Oh well, try again.<a href=javascript:history.back();>back</a>"

response.end
end if

<form name="myform" method="post" action="list.asp">
<table
<TR>
<TD><%=rs("title")%></TD>
<TD><%=rs("capcity")%></TD>
<TD><%=rs("airline")%></TD>
</TR><%
</table>
</form>


That's all! .........unless I misunderstood you.
Oh, don't forget to clean up.

buntine
04-08-2004, 02:02 PM
Good job on replying to this one! I had absolutely no idea what petrod was talking about... :p