ASP and HTML

A

Amateur

Dear Sirs
I have a ASP which shows records from my DBtable. You can see it on:
http://www.bellfield-barna.com/test/optionopenorders4300100090001.asp
OK, now the problem:
I would like that the output is in a html code, using the before mentioned
code (because I would like to change the layout). Can someone tell me where I
find examples or better, how to do that on a step-to-step basis?
Thanks
Klaus

here is my Code from the above mentioned page (I am not asking to write me a
new code - just give me a hint):

<!--VB ADO Constants file. Needed for the ad... constants we use-->
<!-- #include file="adovbs.inc" -->
<%
' BEGIN USER CONSTANTS
Dim CONN_STRING

' I'm using a DSN-less connection.
' To use a DSN, the format is shown on the next line:
'CONN_STRING =
"DSN=access;Database=f:\www.bellfield-barna.com\Data\transferdb.mdb;"

CONN_STRING = "DBQ=" & Server.MapPath("webopenoptionorders430010009000") & ";"
CONN_STRING = CONN_STRING & "Driver={Microsoft Access Driver (*.mdb)};"

' Our SQL code - overriding values we just set
' Comment out to use Access
CONN_STRING =
"DSN=access;Database=f:\www.bellfield-barna.com\Data\transferdb.mdb;"
' END USER CONSTANTS


' BEGIN RUNTIME CODE
' Declare our vars
Dim iPageSize 'How big our pages are
Dim iPageCount 'The number of pages we get back
Dim iPageCurrent 'The page we want to show
Dim strOrderBy 'A fake parameter used to illustrate passing them
Dim strSQL 'SQL command to execute
Dim objPagingConn 'The ADODB connection object
Dim objPagingRS 'The ADODB recordset object
Dim iRecordsShown 'Loop controller for displaying just iPageSize records
Dim I 'Standard looping var

' Get parameters
iPageSize = 1 ' You could easily allow users to change this

' Retrieve page to show or default to 1
If Request.QueryString("page") = "" Then
iPageCurrent = 1
Else
iPageCurrent = CInt(Request.QueryString("page"))
End If

' If you're doing this script with a search or something
' you'll need to pass the sql from page to page. I'm just
' paging through the entire table so I just hard coded it.
' What you show is irrelevant to the point of the sample.
'strSQL = "SELECT * FROM webopenoptionorders430010009000 ORDER BY tradeid;"

' Sept 30, 1999: Code Change
' Based on the non stop questions about how to pass parameters
' from page to page, I'm implementing it so I can stop answering
' the question of how to do it. I personally think this should
' be done based on the specific situation and is clearer if done
' in the same method on all pages, but it's really up to you.
' I'm going to be passing the ORDER BY parameter for illustration.

' This is where you read in parameters you'll need for your query.
' Read in order or default to id
'If Request.QueryString("order") = "" Then
' strOrderBy = "tradeid"
'Else
' strOrderBy = Replace(Request.QueryString("order"), "'", "''")
'End If

' Make sure the input is one of our fields.
strOrderBy = LCase(Request.QueryString("order"))
Select Case strOrderBy
Case "fecha", "tradeid", "clearingnumber", "bought", "sold", "commodity",
"month", "year", "strikeprice", "putorcall", "premium", "settlementprice",
"optionvalue"
' A little pointless, but...
strOrderBy = strOrderBy
Case Else
strOrderBy = "tradeid"
End Select

' Build our SQL String using the parameters we just got.
strSQL = "SELECT * FROM webopenoptionorders430010009000 ORDER BY " &
strOrderBy & ";"

' Some lines I used while writing to debug... uh "test", yeah that's it!
' Left them FYI.
'strSQL = "SELECT * FROM webopenoptionorders430010009000 WHERE tradeid=1
ORDER BY tradeid;"
'strSQL = "SELECT * FROM webopenoptionorders430010009000;"
'Response.Write "SQL Query: " & strSQL & "<BR>" & vbCrLf


' Now we finally get to the DB work...
' Create and open our connection
Set objPagingConn = Server.CreateObject("ADODB.Connection")
objPagingConn.Open CONN_STRING

' Create recordset and set the page size
Set objPagingRS = Server.CreateObject("ADODB.Recordset")
objPagingRS.PageSize = iPageSize

' You can change other settings as with any RS
'objPagingRS.CursorLocation = adUseClient
objPagingRS.CacheSize = iPageSize

' Open RS
objPagingRS.Open strSQL, objPagingConn, adOpenStatic, adLockReadOnly,
adCmdText

' Get the count of the pages using the given page size
iPageCount = objPagingRS.PageCount

' If the request page falls outside the acceptable range,
' give them the closest match (1 or max)
If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
If iPageCurrent < 1 Then iPageCurrent = 1

' Check page count to prevent bombing when zero results are returned!
If iPageCount = 0 Then
Response.Write "No records found!"
Else
' Move to the selected page
objPagingRS.AbsolutePage = iPageCurrent

' Start output with a page x of n line
%>
<p>
<font size="+1">Record <strong><%= iPageCurrent %></strong>
of <strong><%= iPageCount %></strong></font>
</p>
<%
' Spacing
Response.Write vbCrLf

' Continue with a title row in our table
Response.Write "<table border=""1"">" & vbCrLf

' Show field names in the top row
Response.Write vbTab & "<tr>" & vbCrLf
For I = 0 To objPagingRS.Fields.Count - 1
Response.Write vbTab & vbTab & "<th>"
Response.Write objPagingRS.Fields(I).Name
Response.Write "</th>" & vbCrLf
Next 'I
Response.Write vbTab & "</tr>" & vbCrLf

' Loop through our records and ouput 1 row per record
iRecordsShown = 0
Do While iRecordsShown < iPageSize And Not objPagingRS.EOF
Response.Write vbTab & "<tr>" & vbCrLf
For I = 0 To objPagingRS.Fields.Count - 1
Response.Write vbTab & vbTab & "<td>"
Response.Write objPagingRS.Fields(I)
Response.Write "</td>" & vbCrLf
Next 'I
Response.Write vbTab & "</tr>" & vbCrLf

' Increment the number of records we've shown
iRecordsShown = iRecordsShown + 1
' Can't forget to move to the next record!
objPagingRS.MoveNext
Loop

' All done - close table
Response.Write "</table>" & vbCrLf
End If

' Close DB objects and free variables
objPagingRS.Close
Set objPagingRS = Nothing
objPagingConn.Close
Set objPagingConn = Nothing


' Show "previous" and "next" page links which pass the page to view
' and any parameters needed to rebuild the query. You could just as
' easily use a form but you'll need to change the lines that read
' the info back in at the top of the script.
If iPageCurrent > 1 Then
%>
<a
href="http://www.bellfield-barna.com/BIE/...-9000/optionopenorders4300100090001.asp?page=<%=
iPageCurrent - 1 %>&order=<%= Server.URLEncode(strOrderBy) %>">[<< Prev]</a>
<%
End If

' You can also show page numbers:
For I = 1 To iPageCount
If I = iPageCurrent Then
%>
<%= I %>
<%
Else
%>
<a
href="http://www.bellfield-barna.com/BIE/...-9000/optionopenorders4300100090001.asp?page=<%=
I %>&order=<%= Server.URLEncode(strOrderBy) %>"><%= I %></a>
<%
End If
Next 'I

If iPageCurrent < iPageCount Then
%>
<a
href="http://www.bellfield-barna.com/BIE/...-9000/optionopenorders4300100090001.asp?page=<%=
iPageCurrent + 1 %>&order=<%= Server.URLEncode(strOrderBy) %>">[Next >>]</a>
<%
End If

' END RUNTIME CODE
%>
 
D

David Berry

The HTML code is in the Response.Write sections of your code. You can't see
it in Design View because it's all written in ASP. What you would have to
do is design the layout you want and then where you see the response.write
end the ASP Code (use %> to end a code block), put in the HTML and then
start the ASP code again (use <% to start it again) so you can see the
tables and layout in HTML View.

For example:

In your code where you see:

Do While iRecordsShown < iPageSize And Not objPagingRS.EOF
Response.Write vbTab & "<tr>" & vbCrLf
For I = 0 To objPagingRS.Fields.Count - 1
Response.Write vbTab & vbTab & "<td>"
Response.Write objPagingRS.Fields(I)
Response.Write "</td>" & vbCrLf
Next 'I
Response.Write vbTab & "</tr>" & vbCrLf

You could change that to:

Do While iRecordsShown < iPageSize And Not objPagingRS.EOF
%>
<tr>
<%
For I = 0 To objPagingRS.Fields.Count - 1
%>
<td><%=objPagingRS.Fields(I)%></td>
<%
Next 'I
%>
<tr>
<%
....... continue ASP Code

What I've done here is removed the Response.Write stuff (Reponses.Write is
ASP code that says "write this to the screen ... ") and replaced it with
actual HTML tags so that now they can be viewed in FrontPage



--
David Berry
FrontPage Support: http://www.frontpagemvps.com/


Amateur said:
Dear Sirs
I have a ASP which shows records from my DBtable. You can see it on:
http://www.bellfield-barna.com/test/optionopenorders4300100090001.asp
OK, now the problem:
I would like that the output is in a html code, using the before mentioned
code (because I would like to change the layout). Can someone tell me
where I
find examples or better, how to do that on a step-to-step basis?
Thanks
Klaus

here is my Code from the above mentioned page (I am not asking to write me
a
new code - just give me a hint):

<!--VB ADO Constants file. Needed for the ad... constants we use-->
<!-- #include file="adovbs.inc" -->
<%
' BEGIN USER CONSTANTS
Dim CONN_STRING

' I'm using a DSN-less connection.
' To use a DSN, the format is shown on the next line:
'CONN_STRING =
"DSN=access;Database=f:\www.bellfield-barna.com\Data\transferdb.mdb;"

CONN_STRING = "DBQ=" & Server.MapPath("webopenoptionorders430010009000") &
";"
CONN_STRING = CONN_STRING & "Driver={Microsoft Access Driver (*.mdb)};"

' Our SQL code - overriding values we just set
' Comment out to use Access
CONN_STRING =
"DSN=access;Database=f:\www.bellfield-barna.com\Data\transferdb.mdb;"
' END USER CONSTANTS


' BEGIN RUNTIME CODE
' Declare our vars
Dim iPageSize 'How big our pages are
Dim iPageCount 'The number of pages we get back
Dim iPageCurrent 'The page we want to show
Dim strOrderBy 'A fake parameter used to illustrate passing them
Dim strSQL 'SQL command to execute
Dim objPagingConn 'The ADODB connection object
Dim objPagingRS 'The ADODB recordset object
Dim iRecordsShown 'Loop controller for displaying just iPageSize records
Dim I 'Standard looping var

' Get parameters
iPageSize = 1 ' You could easily allow users to change this

' Retrieve page to show or default to 1
If Request.QueryString("page") = "" Then
iPageCurrent = 1
Else
iPageCurrent = CInt(Request.QueryString("page"))
End If

' If you're doing this script with a search or something
' you'll need to pass the sql from page to page. I'm just
' paging through the entire table so I just hard coded it.
' What you show is irrelevant to the point of the sample.
'strSQL = "SELECT * FROM webopenoptionorders430010009000 ORDER BY
tradeid;"

' Sept 30, 1999: Code Change
' Based on the non stop questions about how to pass parameters
' from page to page, I'm implementing it so I can stop answering
' the question of how to do it. I personally think this should
' be done based on the specific situation and is clearer if done
' in the same method on all pages, but it's really up to you.
' I'm going to be passing the ORDER BY parameter for illustration.

' This is where you read in parameters you'll need for your query.
' Read in order or default to id
'If Request.QueryString("order") = "" Then
' strOrderBy = "tradeid"
'Else
' strOrderBy = Replace(Request.QueryString("order"), "'", "''")
'End If

' Make sure the input is one of our fields.
strOrderBy = LCase(Request.QueryString("order"))
Select Case strOrderBy
Case "fecha", "tradeid", "clearingnumber", "bought", "sold", "commodity",
"month", "year", "strikeprice", "putorcall", "premium", "settlementprice",
"optionvalue"
' A little pointless, but...
strOrderBy = strOrderBy
Case Else
strOrderBy = "tradeid"
End Select

' Build our SQL String using the parameters we just got.
strSQL = "SELECT * FROM webopenoptionorders430010009000 ORDER BY " &
strOrderBy & ";"

' Some lines I used while writing to debug... uh "test", yeah that's it!
' Left them FYI.
'strSQL = "SELECT * FROM webopenoptionorders430010009000 WHERE tradeid=1
ORDER BY tradeid;"
'strSQL = "SELECT * FROM webopenoptionorders430010009000;"
'Response.Write "SQL Query: " & strSQL & "<BR>" & vbCrLf


' Now we finally get to the DB work...
' Create and open our connection
Set objPagingConn = Server.CreateObject("ADODB.Connection")
objPagingConn.Open CONN_STRING

' Create recordset and set the page size
Set objPagingRS = Server.CreateObject("ADODB.Recordset")
objPagingRS.PageSize = iPageSize

' You can change other settings as with any RS
'objPagingRS.CursorLocation = adUseClient
objPagingRS.CacheSize = iPageSize

' Open RS
objPagingRS.Open strSQL, objPagingConn, adOpenStatic, adLockReadOnly,
adCmdText

' Get the count of the pages using the given page size
iPageCount = objPagingRS.PageCount

' If the request page falls outside the acceptable range,
' give them the closest match (1 or max)
If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
If iPageCurrent < 1 Then iPageCurrent = 1

' Check page count to prevent bombing when zero results are returned!
If iPageCount = 0 Then
Response.Write "No records found!"
Else
' Move to the selected page
objPagingRS.AbsolutePage = iPageCurrent

' Start output with a page x of n line
%>
<p>
<font size="+1">Record <strong><%= iPageCurrent %></strong>
of <strong><%= iPageCount %></strong></font>
</p>
<%
' Spacing
Response.Write vbCrLf

' Continue with a title row in our table
Response.Write "<table border=""1"">" & vbCrLf

' Show field names in the top row
Response.Write vbTab & "<tr>" & vbCrLf
For I = 0 To objPagingRS.Fields.Count - 1
Response.Write vbTab & vbTab & "<th>"
Response.Write objPagingRS.Fields(I).Name
Response.Write "</th>" & vbCrLf
Next 'I
Response.Write vbTab & "</tr>" & vbCrLf

' Loop through our records and ouput 1 row per record
iRecordsShown = 0
Do While iRecordsShown < iPageSize And Not objPagingRS.EOF
Response.Write vbTab & "<tr>" & vbCrLf
For I = 0 To objPagingRS.Fields.Count - 1
Response.Write vbTab & vbTab & "<td>"
Response.Write objPagingRS.Fields(I)
Response.Write "</td>" & vbCrLf
Next 'I
Response.Write vbTab & "</tr>" & vbCrLf

' Increment the number of records we've shown
iRecordsShown = iRecordsShown + 1
' Can't forget to move to the next record!
objPagingRS.MoveNext
Loop

' All done - close table
Response.Write "</table>" & vbCrLf
End If

' Close DB objects and free variables
objPagingRS.Close
Set objPagingRS = Nothing
objPagingConn.Close
Set objPagingConn = Nothing


' Show "previous" and "next" page links which pass the page to view
' and any parameters needed to rebuild the query. You could just as
' easily use a form but you'll need to change the lines that read
' the info back in at the top of the script.
If iPageCurrent > 1 Then
%>
<a
href="http://www.bellfield-barna.com/BIE/...-9000/optionopenorders4300100090001.asp?page=<%=
iPageCurrent - 1 %>&order=<%= Server.URLEncode(strOrderBy) %>">[<<
Prev]</a>
<%
End If

' You can also show page numbers:
For I = 1 To iPageCount
If I = iPageCurrent Then
%>
<%= I %>
<%
Else
%>
<a
href="http://www.bellfield-barna.com/BIE/...-9000/optionopenorders4300100090001.asp?page=<%=
I %>&order=<%= Server.URLEncode(strOrderBy) %>"><%= I %></a>
<%
End If
Next 'I

If iPageCurrent < iPageCount Then
%>
<a
href="http://www.bellfield-barna.com/BIE/...-9000/optionopenorders4300100090001.asp?page=<%=
iPageCurrent + 1 %>&order= said:
<%
End If

' END RUNTIME CODE
%>
 
A

Amateur

I changed the section so as you told me to, but I still cannot see the
tables and layout in HTML View. Is there something what I misunderstood in
your last message?
Thanks
Klaus


David Berry said:
The HTML code is in the Response.Write sections of your code. You can't see
it in Design View because it's all written in ASP. What you would have to
do is design the layout you want and then where you see the response.write
end the ASP Code (use %> to end a code block), put in the HTML and then
start the ASP code again (use <% to start it again) so you can see the
tables and layout in HTML View.

For example:

In your code where you see:

Do While iRecordsShown < iPageSize And Not objPagingRS.EOF
Response.Write vbTab & "<tr>" & vbCrLf
For I = 0 To objPagingRS.Fields.Count - 1
Response.Write vbTab & vbTab & "<td>"
Response.Write objPagingRS.Fields(I)
Response.Write "</td>" & vbCrLf
Next 'I
Response.Write vbTab & "</tr>" & vbCrLf

You could change that to:

Do While iRecordsShown < iPageSize And Not objPagingRS.EOF
%>
<tr>
<%
For I = 0 To objPagingRS.Fields.Count - 1
%>
<td><%=objPagingRS.Fields(I)%></td>
<%
Next 'I
%>
<tr>
<%
....... continue ASP Code

What I've done here is removed the Response.Write stuff (Reponses.Write is
ASP code that says "write this to the screen ... ") and replaced it with
actual HTML tags so that now they can be viewed in FrontPage



--
David Berry
FrontPage Support: http://www.frontpagemvps.com/


Amateur said:
Dear Sirs
I have a ASP which shows records from my DBtable. You can see it on:
http://www.bellfield-barna.com/test/optionopenorders4300100090001.asp
OK, now the problem:
I would like that the output is in a html code, using the before mentioned
code (because I would like to change the layout). Can someone tell me
where I
find examples or better, how to do that on a step-to-step basis?
Thanks
Klaus

here is my Code from the above mentioned page (I am not asking to write me
a
new code - just give me a hint):

<!--VB ADO Constants file. Needed for the ad... constants we use-->
<!-- #include file="adovbs.inc" -->
<%
' BEGIN USER CONSTANTS
Dim CONN_STRING

' I'm using a DSN-less connection.
' To use a DSN, the format is shown on the next line:
'CONN_STRING =
"DSN=access;Database=f:\www.bellfield-barna.com\Data\transferdb.mdb;"

CONN_STRING = "DBQ=" & Server.MapPath("webopenoptionorders430010009000") &
";"
CONN_STRING = CONN_STRING & "Driver={Microsoft Access Driver (*.mdb)};"

' Our SQL code - overriding values we just set
' Comment out to use Access
CONN_STRING =
"DSN=access;Database=f:\www.bellfield-barna.com\Data\transferdb.mdb;"
' END USER CONSTANTS


' BEGIN RUNTIME CODE
' Declare our vars
Dim iPageSize 'How big our pages are
Dim iPageCount 'The number of pages we get back
Dim iPageCurrent 'The page we want to show
Dim strOrderBy 'A fake parameter used to illustrate passing them
Dim strSQL 'SQL command to execute
Dim objPagingConn 'The ADODB connection object
Dim objPagingRS 'The ADODB recordset object
Dim iRecordsShown 'Loop controller for displaying just iPageSize records
Dim I 'Standard looping var

' Get parameters
iPageSize = 1 ' You could easily allow users to change this

' Retrieve page to show or default to 1
If Request.QueryString("page") = "" Then
iPageCurrent = 1
Else
iPageCurrent = CInt(Request.QueryString("page"))
End If

' If you're doing this script with a search or something
' you'll need to pass the sql from page to page. I'm just
' paging through the entire table so I just hard coded it.
' What you show is irrelevant to the point of the sample.
'strSQL = "SELECT * FROM webopenoptionorders430010009000 ORDER BY
tradeid;"

' Sept 30, 1999: Code Change
' Based on the non stop questions about how to pass parameters
' from page to page, I'm implementing it so I can stop answering
' the question of how to do it. I personally think this should
' be done based on the specific situation and is clearer if done
' in the same method on all pages, but it's really up to you.
' I'm going to be passing the ORDER BY parameter for illustration.

' This is where you read in parameters you'll need for your query.
' Read in order or default to id
'If Request.QueryString("order") = "" Then
' strOrderBy = "tradeid"
'Else
' strOrderBy = Replace(Request.QueryString("order"), "'", "''")
'End If

' Make sure the input is one of our fields.
strOrderBy = LCase(Request.QueryString("order"))
Select Case strOrderBy
Case "fecha", "tradeid", "clearingnumber", "bought", "sold", "commodity",
"month", "year", "strikeprice", "putorcall", "premium", "settlementprice",
"optionvalue"
' A little pointless, but...
strOrderBy = strOrderBy
Case Else
strOrderBy = "tradeid"
End Select

' Build our SQL String using the parameters we just got.
strSQL = "SELECT * FROM webopenoptionorders430010009000 ORDER BY " &
strOrderBy & ";"

' Some lines I used while writing to debug... uh "test", yeah that's it!
' Left them FYI.
'strSQL = "SELECT * FROM webopenoptionorders430010009000 WHERE tradeid=1
ORDER BY tradeid;"
'strSQL = "SELECT * FROM webopenoptionorders430010009000;"
'Response.Write "SQL Query: " & strSQL & "<BR>" & vbCrLf


' Now we finally get to the DB work...
' Create and open our connection
Set objPagingConn = Server.CreateObject("ADODB.Connection")
objPagingConn.Open CONN_STRING

' Create recordset and set the page size
Set objPagingRS = Server.CreateObject("ADODB.Recordset")
objPagingRS.PageSize = iPageSize

' You can change other settings as with any RS
'objPagingRS.CursorLocation = adUseClient
objPagingRS.CacheSize = iPageSize

' Open RS
objPagingRS.Open strSQL, objPagingConn, adOpenStatic, adLockReadOnly,
adCmdText

' Get the count of the pages using the given page size
iPageCount = objPagingRS.PageCount

' If the request page falls outside the acceptable range,
' give them the closest match (1 or max)
If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
If iPageCurrent < 1 Then iPageCurrent = 1

' Check page count to prevent bombing when zero results are returned!
If iPageCount = 0 Then
Response.Write "No records found!"
Else
' Move to the selected page
objPagingRS.AbsolutePage = iPageCurrent

' Start output with a page x of n line
%>
<p>
<font size="+1">Record <strong><%= iPageCurrent %></strong>
of <strong><%= iPageCount %></strong></font>
</p>
<%
' Spacing
Response.Write vbCrLf

' Continue with a title row in our table
Response.Write "<table border=""1"">" & vbCrLf

' Show field names in the top row
Response.Write vbTab & "<tr>" & vbCrLf
For I = 0 To objPagingRS.Fields.Count - 1
Response.Write vbTab & vbTab & "<th>"
Response.Write objPagingRS.Fields(I).Name
Response.Write "</th>" & vbCrLf
Next 'I
Response.Write vbTab & "</tr>" & vbCrLf

' Loop through our records and ouput 1 row per record
iRecordsShown = 0
Do While iRecordsShown < iPageSize And Not objPagingRS.EOF
Response.Write vbTab & "<tr>" & vbCrLf
For I = 0 To objPagingRS.Fields.Count - 1
Response.Write vbTab & vbTab & "<td>"
Response.Write objPagingRS.Fields(I)
Response.Write "</td>" & vbCrLf
Next 'I
Response.Write vbTab & "</tr>" & vbCrLf

' Increment the number of records we've shown
iRecordsShown = iRecordsShown + 1
' Can't forget to move to the next record!
objPagingRS.MoveNext
Loop

' All done - close table
Response.Write "</table>" & vbCrLf
End If

' Close DB objects and free variables
objPagingRS.Close
Set objPagingRS = Nothing
objPagingConn.Close
Set objPagingConn = Nothing


' Show "previous" and "next" page links which pass the page to view
' and any parameters needed to rebuild the query. You could just as
' easily use a form but you'll need to change the lines that read
' the info back in at the top of the script.
If iPageCurrent > 1 Then
%>
<a
href="http://www.bellfield-barna.com/BIE/...-9000/optionopenorders4300100090001.asp?page=<%=
iPageCurrent - 1 %>&order=<%= Server.URLEncode(strOrderBy) %>">[<<
Prev]</a>
<%
End If

' You can also show page numbers:
For I = 1 To iPageCount
If I = iPageCurrent Then
%>
<%= I %>
<%
Else
%>
<a
href="http://www.bellfield-barna.com/BIE/...-9000/optionopenorders4300100090001.asp?page=<%=
I %>&order=<%= Server.URLEncode(strOrderBy) %>"><%= I %></a>
<%
End If
Next 'I

If iPageCurrent < iPageCount Then
%>
<a
href="http://www.bellfield-barna.com/BIE/...-9000/optionopenorders4300100090001.asp?page=<%=
iPageCurrent + 1 %>&order= said:
<%
End If

' END RUNTIME CODE
%>
 
M

Mike Mueller

I would highly recommend that you rename / relocate your
database file before you get to far into this, as you posted
its url



message
: Dear Sirs
: I have a ASP which shows records from my DBtable. You can
see it on:
:
http://www.bellfield-barna.com/test/optionopenorders4300100090001.asp
: OK, now the problem:
: I would like that the output is in a html code, using the
before mentioned
: code (because I would like to change the layout). Can
someone tell me where I
: find examples or better, how to do that on a step-to-step
basis?
: Thanks
: Klaus
:
: here is my Code from the above mentioned page (I am not
asking to write me a
: new code - just give me a hint):
:
: <!--VB ADO Constants file. Needed for the ad... constants
we use-->
: <!-- #include file="adovbs.inc" -->
: <%
: ' BEGIN USER CONSTANTS
: Dim CONN_STRING
:
: ' I'm using a DSN-less connection.
: ' To use a DSN, the format is shown on the next line:
: 'CONN_STRING =
:
"DSN=access;Database=f:\www.bellfield-barna.com\Data\transferdb.mdb;"
:
: CONN_STRING = "DBQ=" &
Server.MapPath("webopenoptionorders430010009000") & ";"
: CONN_STRING = CONN_STRING & "Driver={Microsoft Access
Driver (*.mdb)};"
:
: ' Our SQL code - overriding values we just set
: ' Comment out to use Access
: CONN_STRING =
:
"DSN=access;Database=f:\www.bellfield-barna.com\Data\transferdb.mdb;"
: ' END USER CONSTANTS
:
:
: ' BEGIN RUNTIME CODE
: ' Declare our vars
: Dim iPageSize 'How big our pages are
: Dim iPageCount 'The number of pages we get back
: Dim iPageCurrent 'The page we want to show
: Dim strOrderBy 'A fake parameter used to illustrate
passing them
: Dim strSQL 'SQL command to execute
: Dim objPagingConn 'The ADODB connection object
: Dim objPagingRS 'The ADODB recordset object
: Dim iRecordsShown 'Loop controller for displaying just
iPageSize records
: Dim I 'Standard looping var
:
: ' Get parameters
: iPageSize = 1 ' You could easily allow users to change
this
:
: ' Retrieve page to show or default to 1
: If Request.QueryString("page") = "" Then
: iPageCurrent = 1
: Else
: iPageCurrent = CInt(Request.QueryString("page"))
: End If
:
: ' If you're doing this script with a search or something
: ' you'll need to pass the sql from page to page. I'm just
: ' paging through the entire table so I just hard coded it.
: ' What you show is irrelevant to the point of the sample.
: 'strSQL = "SELECT * FROM webopenoptionorders430010009000
ORDER BY tradeid;"
:
: ' Sept 30, 1999: Code Change
: ' Based on the non stop questions about how to pass
parameters
: ' from page to page, I'm implementing it so I can stop
answering
: ' the question of how to do it. I personally think this
should
: ' be done based on the specific situation and is clearer
if done
: ' in the same method on all pages, but it's really up to
you.
: ' I'm going to be passing the ORDER BY parameter for
illustration.
:
: ' This is where you read in parameters you'll need for
your query.
: ' Read in order or default to id
: 'If Request.QueryString("order") = "" Then
: ' strOrderBy = "tradeid"
: 'Else
: ' strOrderBy = Replace(Request.QueryString("order"), "'",
"''")
: 'End If
:
: ' Make sure the input is one of our fields.
: strOrderBy = LCase(Request.QueryString("order"))
: Select Case strOrderBy
: Case "fecha", "tradeid", "clearingnumber", "bought",
"sold", "commodity",
: "month", "year", "strikeprice", "putorcall", "premium",
"settlementprice",
: "optionvalue"
: ' A little pointless, but...
: strOrderBy = strOrderBy
: Case Else
: strOrderBy = "tradeid"
: End Select
:
: ' Build our SQL String using the parameters we just got.
: strSQL = "SELECT * FROM webopenoptionorders430010009000
ORDER BY " &
: strOrderBy & ";"
:
: ' Some lines I used while writing to debug... uh "test",
yeah that's it!
: ' Left them FYI.
: 'strSQL = "SELECT * FROM webopenoptionorders430010009000
WHERE tradeid=1
: ORDER BY tradeid;"
: 'strSQL = "SELECT * FROM webopenoptionorders430010009000;"
: 'Response.Write "SQL Query: " & strSQL & "<BR>" & vbCrLf
:
:
: ' Now we finally get to the DB work...
: ' Create and open our connection
: Set objPagingConn =
Server.CreateObject("ADODB.Connection")
: objPagingConn.Open CONN_STRING
:
: ' Create recordset and set the page size
: Set objPagingRS = Server.CreateObject("ADODB.Recordset")
: objPagingRS.PageSize = iPageSize
:
: ' You can change other settings as with any RS
: 'objPagingRS.CursorLocation = adUseClient
: objPagingRS.CacheSize = iPageSize
:
: ' Open RS
: objPagingRS.Open strSQL, objPagingConn, adOpenStatic,
adLockReadOnly,
: adCmdText
:
: ' Get the count of the pages using the given page size
: iPageCount = objPagingRS.PageCount
:
: ' If the request page falls outside the acceptable range,
: ' give them the closest match (1 or max)
: If iPageCurrent > iPageCount Then iPageCurrent =
iPageCount
: If iPageCurrent < 1 Then iPageCurrent = 1
:
: ' Check page count to prevent bombing when zero results
are returned!
: If iPageCount = 0 Then
: Response.Write "No records found!"
: Else
: ' Move to the selected page
: objPagingRS.AbsolutePage = iPageCurrent
:
: ' Start output with a page x of n line
: %>
: <p>
: <font size="+1">Record <strong><%= iPageCurrent
%></strong>
: of <strong><%= iPageCount %></strong></font>
: </p>
: <%
: ' Spacing
: Response.Write vbCrLf
:
: ' Continue with a title row in our table
: Response.Write "<table border=""1"">" & vbCrLf
:
: ' Show field names in the top row
: Response.Write vbTab & "<tr>" & vbCrLf
: For I = 0 To objPagingRS.Fields.Count - 1
: Response.Write vbTab & vbTab & "<th>"
: Response.Write objPagingRS.Fields(I).Name
: Response.Write "</th>" & vbCrLf
: Next 'I
: Response.Write vbTab & "</tr>" & vbCrLf
:
: ' Loop through our records and ouput 1 row per record
: iRecordsShown = 0
: Do While iRecordsShown < iPageSize And Not objPagingRS.EOF
: Response.Write vbTab & "<tr>" & vbCrLf
: For I = 0 To objPagingRS.Fields.Count - 1
: Response.Write vbTab & vbTab & "<td>"
: Response.Write objPagingRS.Fields(I)
: Response.Write "</td>" & vbCrLf
: Next 'I
: Response.Write vbTab & "</tr>" & vbCrLf
:
: ' Increment the number of records we've shown
: iRecordsShown = iRecordsShown + 1
: ' Can't forget to move to the next record!
: objPagingRS.MoveNext
: Loop
:
: ' All done - close table
: Response.Write "</table>" & vbCrLf
: End If
:
: ' Close DB objects and free variables
: objPagingRS.Close
: Set objPagingRS = Nothing
: objPagingConn.Close
: Set objPagingConn = Nothing
:
:
: ' Show "previous" and "next" page links which pass the
page to view
: ' and any parameters needed to rebuild the query. You
could just as
: ' easily use a form but you'll need to change the lines
that read
: ' the info back in at the top of the script.
: If iPageCurrent > 1 Then
: %>
: <a
:
href="http://www.bellfield-barna.com/BIE/...-9000/optionopenorders4300100090001.asp?page=<%=
: iPageCurrent - 1 %>&order=<%= Server.URLEncode(strOrderBy)
%>">[<< Prev]</a>
: <%
: End If
:
: ' You can also show page numbers:
: For I = 1 To iPageCount
: If I = iPageCurrent Then
: %>
: <%= I %>
: <%
: Else
: %>
: <a
:
href="http://www.bellfield-barna.com/BIE/...-9000/optionopenorders4300100090001.asp?page=<%=
: I %>&order=<%= Server.URLEncode(strOrderBy) %>"><%= I
%></a>
: <%
: End If
: Next 'I
:
: If iPageCurrent < iPageCount Then
: %>
: <a
:
href="http://www.bellfield-barna.com/BIE/...-9000/optionopenorders4300100090001.asp?page=<%=
: iPageCurrent + 1 %>&order=<%= Server.URLEncode(strOrderBy)
%>">[Next >>]</a>
: <%
: End If
:
: ' END RUNTIME CODE
: %>
:
:
:
 
A

Amateur

Do I understand correct?
In your sample code where you write <td><%=objPagingRS.Fields(I)%></td>
I have to input my fields which I would like to show. like:
<td width="306"><input class="formpagetablefield" type="text"
style="text-align: right; font-family: Tahoma; font-size: 8pt;"
name="bought" size="50" Value="<%=trim(rstable("bought"))%>"></td>
If yes than my field value is wrong with
Value="<%=trim(rstable("bought"))%>">
Can you tell me what to write instead to receive my data in that field?

David Berry said:
The HTML code is in the Response.Write sections of your code. You can't see
it in Design View because it's all written in ASP. What you would have to
do is design the layout you want and then where you see the response.write
end the ASP Code (use %> to end a code block), put in the HTML and then
start the ASP code again (use <% to start it again) so you can see the
tables and layout in HTML View.

For example:

In your code where you see:

Do While iRecordsShown < iPageSize And Not objPagingRS.EOF
Response.Write vbTab & "<tr>" & vbCrLf
For I = 0 To objPagingRS.Fields.Count - 1
Response.Write vbTab & vbTab & "<td>"
Response.Write objPagingRS.Fields(I)
Response.Write "</td>" & vbCrLf
Next 'I
Response.Write vbTab & "</tr>" & vbCrLf

You could change that to:

Do While iRecordsShown < iPageSize And Not objPagingRS.EOF
%>
<tr>
<%
For I = 0 To objPagingRS.Fields.Count - 1
%>
<td><%=objPagingRS.Fields(I)%></td>
<%
Next 'I
%>
<tr>
<%
....... continue ASP Code

What I've done here is removed the Response.Write stuff (Reponses.Write is
ASP code that says "write this to the screen ... ") and replaced it with
actual HTML tags so that now they can be viewed in FrontPage



--
David Berry
FrontPage Support: http://www.frontpagemvps.com/


Amateur said:
Dear Sirs
I have a ASP which shows records from my DBtable. You can see it on:
http://www.bellfield-barna.com/test/optionopenorders4300100090001.asp
OK, now the problem:
I would like that the output is in a html code, using the before mentioned
code (because I would like to change the layout). Can someone tell me
where I
find examples or better, how to do that on a step-to-step basis?
Thanks
Klaus

here is my Code from the above mentioned page (I am not asking to write me
a
new code - just give me a hint):

<!--VB ADO Constants file. Needed for the ad... constants we use-->
<!-- #include file="adovbs.inc" -->
<%
' BEGIN USER CONSTANTS
Dim CONN_STRING

' I'm using a DSN-less connection.
' To use a DSN, the format is shown on the next line:
'CONN_STRING =
"DSN=access;Database=f:\www.bellfield-barna.com\Data\transferdb.mdb;"

CONN_STRING = "DBQ=" & Server.MapPath("webopenoptionorders430010009000") &
";"
CONN_STRING = CONN_STRING & "Driver={Microsoft Access Driver (*.mdb)};"

' Our SQL code - overriding values we just set
' Comment out to use Access
CONN_STRING =
"DSN=access;Database=f:\www.bellfield-barna.com\Data\transferdb.mdb;"
' END USER CONSTANTS


' BEGIN RUNTIME CODE
' Declare our vars
Dim iPageSize 'How big our pages are
Dim iPageCount 'The number of pages we get back
Dim iPageCurrent 'The page we want to show
Dim strOrderBy 'A fake parameter used to illustrate passing them
Dim strSQL 'SQL command to execute
Dim objPagingConn 'The ADODB connection object
Dim objPagingRS 'The ADODB recordset object
Dim iRecordsShown 'Loop controller for displaying just iPageSize records
Dim I 'Standard looping var

' Get parameters
iPageSize = 1 ' You could easily allow users to change this

' Retrieve page to show or default to 1
If Request.QueryString("page") = "" Then
iPageCurrent = 1
Else
iPageCurrent = CInt(Request.QueryString("page"))
End If

' If you're doing this script with a search or something
' you'll need to pass the sql from page to page. I'm just
' paging through the entire table so I just hard coded it.
' What you show is irrelevant to the point of the sample.
'strSQL = "SELECT * FROM webopenoptionorders430010009000 ORDER BY
tradeid;"

' Sept 30, 1999: Code Change
' Based on the non stop questions about how to pass parameters
' from page to page, I'm implementing it so I can stop answering
' the question of how to do it. I personally think this should
' be done based on the specific situation and is clearer if done
' in the same method on all pages, but it's really up to you.
' I'm going to be passing the ORDER BY parameter for illustration.

' This is where you read in parameters you'll need for your query.
' Read in order or default to id
'If Request.QueryString("order") = "" Then
' strOrderBy = "tradeid"
'Else
' strOrderBy = Replace(Request.QueryString("order"), "'", "''")
'End If

' Make sure the input is one of our fields.
strOrderBy = LCase(Request.QueryString("order"))
Select Case strOrderBy
Case "fecha", "tradeid", "clearingnumber", "bought", "sold", "commodity",
"month", "year", "strikeprice", "putorcall", "premium", "settlementprice",
"optionvalue"
' A little pointless, but...
strOrderBy = strOrderBy
Case Else
strOrderBy = "tradeid"
End Select

' Build our SQL String using the parameters we just got.
strSQL = "SELECT * FROM webopenoptionorders430010009000 ORDER BY " &
strOrderBy & ";"

' Some lines I used while writing to debug... uh "test", yeah that's it!
' Left them FYI.
'strSQL = "SELECT * FROM webopenoptionorders430010009000 WHERE tradeid=1
ORDER BY tradeid;"
'strSQL = "SELECT * FROM webopenoptionorders430010009000;"
'Response.Write "SQL Query: " & strSQL & "<BR>" & vbCrLf


' Now we finally get to the DB work...
' Create and open our connection
Set objPagingConn = Server.CreateObject("ADODB.Connection")
objPagingConn.Open CONN_STRING

' Create recordset and set the page size
Set objPagingRS = Server.CreateObject("ADODB.Recordset")
objPagingRS.PageSize = iPageSize

' You can change other settings as with any RS
'objPagingRS.CursorLocation = adUseClient
objPagingRS.CacheSize = iPageSize

' Open RS
objPagingRS.Open strSQL, objPagingConn, adOpenStatic, adLockReadOnly,
adCmdText

' Get the count of the pages using the given page size
iPageCount = objPagingRS.PageCount

' If the request page falls outside the acceptable range,
' give them the closest match (1 or max)
If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
If iPageCurrent < 1 Then iPageCurrent = 1

' Check page count to prevent bombing when zero results are returned!
If iPageCount = 0 Then
Response.Write "No records found!"
Else
' Move to the selected page
objPagingRS.AbsolutePage = iPageCurrent

' Start output with a page x of n line
%>
<p>
<font size="+1">Record <strong><%= iPageCurrent %></strong>
of <strong><%= iPageCount %></strong></font>
</p>
<%
' Spacing
Response.Write vbCrLf

' Continue with a title row in our table
Response.Write "<table border=""1"">" & vbCrLf

' Show field names in the top row
Response.Write vbTab & "<tr>" & vbCrLf
For I = 0 To objPagingRS.Fields.Count - 1
Response.Write vbTab & vbTab & "<th>"
Response.Write objPagingRS.Fields(I).Name
Response.Write "</th>" & vbCrLf
Next 'I
Response.Write vbTab & "</tr>" & vbCrLf

' Loop through our records and ouput 1 row per record
iRecordsShown = 0
Do While iRecordsShown < iPageSize And Not objPagingRS.EOF
Response.Write vbTab & "<tr>" & vbCrLf
For I = 0 To objPagingRS.Fields.Count - 1
Response.Write vbTab & vbTab & "<td>"
Response.Write objPagingRS.Fields(I)
Response.Write "</td>" & vbCrLf
Next 'I
Response.Write vbTab & "</tr>" & vbCrLf

' Increment the number of records we've shown
iRecordsShown = iRecordsShown + 1
' Can't forget to move to the next record!
objPagingRS.MoveNext
Loop

' All done - close table
Response.Write "</table>" & vbCrLf
End If

' Close DB objects and free variables
objPagingRS.Close
Set objPagingRS = Nothing
objPagingConn.Close
Set objPagingConn = Nothing


' Show "previous" and "next" page links which pass the page to view
' and any parameters needed to rebuild the query. You could just as
' easily use a form but you'll need to change the lines that read
' the info back in at the top of the script.
If iPageCurrent > 1 Then
%>
<a
href="http://www.bellfield-barna.com/BIE/...-9000/optionopenorders4300100090001.asp?page=<%=
iPageCurrent - 1 %>&order=<%= Server.URLEncode(strOrderBy) %>">[<<
Prev]</a>
<%
End If

' You can also show page numbers:
For I = 1 To iPageCount
If I = iPageCurrent Then
%>
<%= I %>
<%
Else
%>
<a
href="http://www.bellfield-barna.com/BIE/...-9000/optionopenorders4300100090001.asp?page=<%=
I %>&order=<%= Server.URLEncode(strOrderBy) %>"><%= I %></a>
<%
End If
Next 'I

If iPageCurrent < iPageCount Then
%>
<a
href="http://www.bellfield-barna.com/BIE/...-9000/optionopenorders4300100090001.asp?page=<%=
iPageCurrent + 1 %>&order= said:
<%
End If

' END RUNTIME CODE
%>
 
A

Amateur

Thanks Mike, but anyway it's only a fictive database with some tables with
only fictive data.
But, if you have time could you have a check as well on my problem?
Thanks
Klaus Müller

Mike Mueller said:
I would highly recommend that you rename / relocate your
database file before you get to far into this, as you posted
its url



message
: Dear Sirs
: I have a ASP which shows records from my DBtable. You can
see it on:
:
http://www.bellfield-barna.com/test/optionopenorders4300100090001.asp
: OK, now the problem:
: I would like that the output is in a html code, using the
before mentioned
: code (because I would like to change the layout). Can
someone tell me where I
: find examples or better, how to do that on a step-to-step
basis?
: Thanks
: Klaus
:
: here is my Code from the above mentioned page (I am not
asking to write me a
: new code - just give me a hint):
:
: <!--VB ADO Constants file. Needed for the ad... constants
we use-->
: <!-- #include file="adovbs.inc" -->
: <%
: ' BEGIN USER CONSTANTS
: Dim CONN_STRING
:
: ' I'm using a DSN-less connection.
: ' To use a DSN, the format is shown on the next line:
: 'CONN_STRING =
:
"DSN=access;Database=f:\www.bellfield-barna.com\Data\transferdb.mdb;"
:
: CONN_STRING = "DBQ=" &
Server.MapPath("webopenoptionorders430010009000") & ";"
: CONN_STRING = CONN_STRING & "Driver={Microsoft Access
Driver (*.mdb)};"
:
: ' Our SQL code - overriding values we just set
: ' Comment out to use Access
: CONN_STRING =
:
"DSN=access;Database=f:\www.bellfield-barna.com\Data\transferdb.mdb;"
: ' END USER CONSTANTS
:
:
: ' BEGIN RUNTIME CODE
: ' Declare our vars
: Dim iPageSize 'How big our pages are
: Dim iPageCount 'The number of pages we get back
: Dim iPageCurrent 'The page we want to show
: Dim strOrderBy 'A fake parameter used to illustrate
passing them
: Dim strSQL 'SQL command to execute
: Dim objPagingConn 'The ADODB connection object
: Dim objPagingRS 'The ADODB recordset object
: Dim iRecordsShown 'Loop controller for displaying just
iPageSize records
: Dim I 'Standard looping var
:
: ' Get parameters
: iPageSize = 1 ' You could easily allow users to change
this
:
: ' Retrieve page to show or default to 1
: If Request.QueryString("page") = "" Then
: iPageCurrent = 1
: Else
: iPageCurrent = CInt(Request.QueryString("page"))
: End If
:
: ' If you're doing this script with a search or something
: ' you'll need to pass the sql from page to page. I'm just
: ' paging through the entire table so I just hard coded it.
: ' What you show is irrelevant to the point of the sample.
: 'strSQL = "SELECT * FROM webopenoptionorders430010009000
ORDER BY tradeid;"
:
: ' Sept 30, 1999: Code Change
: ' Based on the non stop questions about how to pass
parameters
: ' from page to page, I'm implementing it so I can stop
answering
: ' the question of how to do it. I personally think this
should
: ' be done based on the specific situation and is clearer
if done
: ' in the same method on all pages, but it's really up to
you.
: ' I'm going to be passing the ORDER BY parameter for
illustration.
:
: ' This is where you read in parameters you'll need for
your query.
: ' Read in order or default to id
: 'If Request.QueryString("order") = "" Then
: ' strOrderBy = "tradeid"
: 'Else
: ' strOrderBy = Replace(Request.QueryString("order"), "'",
"''")
: 'End If
:
: ' Make sure the input is one of our fields.
: strOrderBy = LCase(Request.QueryString("order"))
: Select Case strOrderBy
: Case "fecha", "tradeid", "clearingnumber", "bought",
"sold", "commodity",
: "month", "year", "strikeprice", "putorcall", "premium",
"settlementprice",
: "optionvalue"
: ' A little pointless, but...
: strOrderBy = strOrderBy
: Case Else
: strOrderBy = "tradeid"
: End Select
:
: ' Build our SQL String using the parameters we just got.
: strSQL = "SELECT * FROM webopenoptionorders430010009000
ORDER BY " &
: strOrderBy & ";"
:
: ' Some lines I used while writing to debug... uh "test",
yeah that's it!
: ' Left them FYI.
: 'strSQL = "SELECT * FROM webopenoptionorders430010009000
WHERE tradeid=1
: ORDER BY tradeid;"
: 'strSQL = "SELECT * FROM webopenoptionorders430010009000;"
: 'Response.Write "SQL Query: " & strSQL & "<BR>" & vbCrLf
:
:
: ' Now we finally get to the DB work...
: ' Create and open our connection
: Set objPagingConn =
Server.CreateObject("ADODB.Connection")
: objPagingConn.Open CONN_STRING
:
: ' Create recordset and set the page size
: Set objPagingRS = Server.CreateObject("ADODB.Recordset")
: objPagingRS.PageSize = iPageSize
:
: ' You can change other settings as with any RS
: 'objPagingRS.CursorLocation = adUseClient
: objPagingRS.CacheSize = iPageSize
:
: ' Open RS
: objPagingRS.Open strSQL, objPagingConn, adOpenStatic,
adLockReadOnly,
: adCmdText
:
: ' Get the count of the pages using the given page size
: iPageCount = objPagingRS.PageCount
:
: ' If the request page falls outside the acceptable range,
: ' give them the closest match (1 or max)
: If iPageCurrent > iPageCount Then iPageCurrent =
iPageCount
: If iPageCurrent < 1 Then iPageCurrent = 1
:
: ' Check page count to prevent bombing when zero results
are returned!
: If iPageCount = 0 Then
: Response.Write "No records found!"
: Else
: ' Move to the selected page
: objPagingRS.AbsolutePage = iPageCurrent
:
: ' Start output with a page x of n line
: %>
: <p>
: <font size="+1">Record <strong><%= iPageCurrent
%></strong>
: of <strong><%= iPageCount %></strong></font>
: </p>
: <%
: ' Spacing
: Response.Write vbCrLf
:
: ' Continue with a title row in our table
: Response.Write "<table border=""1"">" & vbCrLf
:
: ' Show field names in the top row
: Response.Write vbTab & "<tr>" & vbCrLf
: For I = 0 To objPagingRS.Fields.Count - 1
: Response.Write vbTab & vbTab & "<th>"
: Response.Write objPagingRS.Fields(I).Name
: Response.Write "</th>" & vbCrLf
: Next 'I
: Response.Write vbTab & "</tr>" & vbCrLf
:
: ' Loop through our records and ouput 1 row per record
: iRecordsShown = 0
: Do While iRecordsShown < iPageSize And Not objPagingRS.EOF
: Response.Write vbTab & "<tr>" & vbCrLf
: For I = 0 To objPagingRS.Fields.Count - 1
: Response.Write vbTab & vbTab & "<td>"
: Response.Write objPagingRS.Fields(I)
: Response.Write "</td>" & vbCrLf
: Next 'I
: Response.Write vbTab & "</tr>" & vbCrLf
:
: ' Increment the number of records we've shown
: iRecordsShown = iRecordsShown + 1
: ' Can't forget to move to the next record!
: objPagingRS.MoveNext
: Loop
:
: ' All done - close table
: Response.Write "</table>" & vbCrLf
: End If
:
: ' Close DB objects and free variables
: objPagingRS.Close
: Set objPagingRS = Nothing
: objPagingConn.Close
: Set objPagingConn = Nothing
:
:
: ' Show "previous" and "next" page links which pass the
page to view
: ' and any parameters needed to rebuild the query. You
could just as
: ' easily use a form but you'll need to change the lines
that read
: ' the info back in at the top of the script.
: If iPageCurrent > 1 Then
: %>
: <a
:
href="http://www.bellfield-barna.com/BIE/...-9000/optionopenorders4300100090001.asp?page=<%=
: iPageCurrent - 1 %>&order=<%= Server.URLEncode(strOrderBy)
%>">[<< Prev]</a>
: <%
: End If
:
: ' You can also show page numbers:
: For I = 1 To iPageCount
: If I = iPageCurrent Then
: %>
: <%= I %>
: <%
: Else
: %>
: <a
:
href="http://www.bellfield-barna.com/BIE/...-9000/optionopenorders4300100090001.asp?page=<%=
: I %>&order=<%= Server.URLEncode(strOrderBy) %>"><%= I
%></a>
: <%
: End If
: Next 'I
:
: If iPageCurrent < iPageCount Then
: %>
: <a
:
href="http://www.bellfield-barna.com/BIE/...-9000/optionopenorders4300100090001.asp?page=<%=
: iPageCurrent + 1 %>&order=<%= Server.URLEncode(strOrderBy)
%>">[Next >>]</a>
: <%
: End If
:
: ' END RUNTIME CODE
: %>
:
:
:
 
S

Stefan B Rusynko

Suggest you look at http://www.w3schools.com/asp/default.asp and the sample at
http://www.asp101.com/samples/db_paged_search.asp (view ASP)

You can't arbitrarily use rstable("bought")
- unless you have created and opened the table with the record set actually named: rstable
Your prior script only opens a record set named: objPagingRS

--

_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
_____________________________________________


| Do I understand correct?
| In your sample code where you write <td><%=objPagingRS.Fields(I)%></td>
| I have to input my fields which I would like to show. like:
| <td width="306"><input class="formpagetablefield" type="text"
| style="text-align: right; font-family: Tahoma; font-size: 8pt;"
| name="bought" size="50" Value="<%=trim(rstable("bought"))%>"></td>
| If yes than my field value is wrong with
| Value="<%=trim(rstable("bought"))%>">
| Can you tell me what to write instead to receive my data in that field?
|
| "David Berry" wrote:
|
| > The HTML code is in the Response.Write sections of your code. You can't see
| > it in Design View because it's all written in ASP. What you would have to
| > do is design the layout you want and then where you see the response.write
| > end the ASP Code (use %> to end a code block), put in the HTML and then
| > start the ASP code again (use <% to start it again) so you can see the
| > tables and layout in HTML View.
| >
| > For example:
| >
| > In your code where you see:
| >
| > Do While iRecordsShown < iPageSize And Not objPagingRS.EOF
| > Response.Write vbTab & "<tr>" & vbCrLf
| > For I = 0 To objPagingRS.Fields.Count - 1
| > Response.Write vbTab & vbTab & "<td>"
| > Response.Write objPagingRS.Fields(I)
| > Response.Write "</td>" & vbCrLf
| > Next 'I
| > Response.Write vbTab & "</tr>" & vbCrLf
| >
| > You could change that to:
| >
| > Do While iRecordsShown < iPageSize And Not objPagingRS.EOF
| > %>
| > <tr>
| > <%
| > For I = 0 To objPagingRS.Fields.Count - 1
| > %>
| > <td><%=objPagingRS.Fields(I)%></td>
| > <%
| > Next 'I
| > %>
| > <tr>
| > <%
| > ....... continue ASP Code
| >
| > What I've done here is removed the Response.Write stuff (Reponses.Write is
| > ASP code that says "write this to the screen ... ") and replaced it with
| > actual HTML tags so that now they can be viewed in FrontPage
| >
| >
| >
| > --
| > David Berry
| > FrontPage Support: http://www.frontpagemvps.com/
| >
| >
| > | > > Dear Sirs
| > > I have a ASP which shows records from my DBtable. You can see it on:
| > > http://www.bellfield-barna.com/test/optionopenorders4300100090001.asp
| > > OK, now the problem:
| > > I would like that the output is in a html code, using the before mentioned
| > > code (because I would like to change the layout). Can someone tell me
| > > where I
| > > find examples or better, how to do that on a step-to-step basis?
| > > Thanks
| > > Klaus
| > >
| > > here is my Code from the above mentioned page (I am not asking to write me
| > > a
| > > new code - just give me a hint):
| > >
| > > <!--VB ADO Constants file. Needed for the ad... constants we use-->
| > > <!-- #include file="adovbs.inc" -->
| > > <%
| > > ' BEGIN USER CONSTANTS
| > > Dim CONN_STRING
| > >
| > > ' I'm using a DSN-less connection.
| > > ' To use a DSN, the format is shown on the next line:
| > > 'CONN_STRING =
| > > "DSN=access;Database=f:\www.bellfield-barna.com\Data\transferdb.mdb;"
| > >
| > > CONN_STRING = "DBQ=" & Server.MapPath("webopenoptionorders430010009000") &
| > > ";"
| > > CONN_STRING = CONN_STRING & "Driver={Microsoft Access Driver (*.mdb)};"
| > >
| > > ' Our SQL code - overriding values we just set
| > > ' Comment out to use Access
| > > CONN_STRING =
| > > "DSN=access;Database=f:\www.bellfield-barna.com\Data\transferdb.mdb;"
| > > ' END USER CONSTANTS
| > >
| > >
| > > ' BEGIN RUNTIME CODE
| > > ' Declare our vars
| > > Dim iPageSize 'How big our pages are
| > > Dim iPageCount 'The number of pages we get back
| > > Dim iPageCurrent 'The page we want to show
| > > Dim strOrderBy 'A fake parameter used to illustrate passing them
| > > Dim strSQL 'SQL command to execute
| > > Dim objPagingConn 'The ADODB connection object
| > > Dim objPagingRS 'The ADODB recordset object
| > > Dim iRecordsShown 'Loop controller for displaying just iPageSize records
| > > Dim I 'Standard looping var
| > >
| > > ' Get parameters
| > > iPageSize = 1 ' You could easily allow users to change this
| > >
| > > ' Retrieve page to show or default to 1
| > > If Request.QueryString("page") = "" Then
| > > iPageCurrent = 1
| > > Else
| > > iPageCurrent = CInt(Request.QueryString("page"))
| > > End If
| > >
| > > ' If you're doing this script with a search or something
| > > ' you'll need to pass the sql from page to page. I'm just
| > > ' paging through the entire table so I just hard coded it.
| > > ' What you show is irrelevant to the point of the sample.
| > > 'strSQL = "SELECT * FROM webopenoptionorders430010009000 ORDER BY
| > > tradeid;"
| > >
| > > ' Sept 30, 1999: Code Change
| > > ' Based on the non stop questions about how to pass parameters
| > > ' from page to page, I'm implementing it so I can stop answering
| > > ' the question of how to do it. I personally think this should
| > > ' be done based on the specific situation and is clearer if done
| > > ' in the same method on all pages, but it's really up to you.
| > > ' I'm going to be passing the ORDER BY parameter for illustration.
| > >
| > > ' This is where you read in parameters you'll need for your query.
| > > ' Read in order or default to id
| > > 'If Request.QueryString("order") = "" Then
| > > ' strOrderBy = "tradeid"
| > > 'Else
| > > ' strOrderBy = Replace(Request.QueryString("order"), "'", "''")
| > > 'End If
| > >
| > > ' Make sure the input is one of our fields.
| > > strOrderBy = LCase(Request.QueryString("order"))
| > > Select Case strOrderBy
| > > Case "fecha", "tradeid", "clearingnumber", "bought", "sold", "commodity",
| > > "month", "year", "strikeprice", "putorcall", "premium", "settlementprice",
| > > "optionvalue"
| > > ' A little pointless, but...
| > > strOrderBy = strOrderBy
| > > Case Else
| > > strOrderBy = "tradeid"
| > > End Select
| > >
| > > ' Build our SQL String using the parameters we just got.
| > > strSQL = "SELECT * FROM webopenoptionorders430010009000 ORDER BY " &
| > > strOrderBy & ";"
| > >
| > > ' Some lines I used while writing to debug... uh "test", yeah that's it!
| > > ' Left them FYI.
| > > 'strSQL = "SELECT * FROM webopenoptionorders430010009000 WHERE tradeid=1
| > > ORDER BY tradeid;"
| > > 'strSQL = "SELECT * FROM webopenoptionorders430010009000;"
| > > 'Response.Write "SQL Query: " & strSQL & "<BR>" & vbCrLf
| > >
| > >
| > > ' Now we finally get to the DB work...
| > > ' Create and open our connection
| > > Set objPagingConn = Server.CreateObject("ADODB.Connection")
| > > objPagingConn.Open CONN_STRING
| > >
| > > ' Create recordset and set the page size
| > > Set objPagingRS = Server.CreateObject("ADODB.Recordset")
| > > objPagingRS.PageSize = iPageSize
| > >
| > > ' You can change other settings as with any RS
| > > 'objPagingRS.CursorLocation = adUseClient
| > > objPagingRS.CacheSize = iPageSize
| > >
| > > ' Open RS
| > > objPagingRS.Open strSQL, objPagingConn, adOpenStatic, adLockReadOnly,
| > > adCmdText
| > >
| > > ' Get the count of the pages using the given page size
| > > iPageCount = objPagingRS.PageCount
| > >
| > > ' If the request page falls outside the acceptable range,
| > > ' give them the closest match (1 or max)
| > > If iPageCurrent > iPageCount Then iPageCurrent = iPageCount
| > > If iPageCurrent < 1 Then iPageCurrent = 1
| > >
| > > ' Check page count to prevent bombing when zero results are returned!
| > > If iPageCount = 0 Then
| > > Response.Write "No records found!"
| > > Else
| > > ' Move to the selected page
| > > objPagingRS.AbsolutePage = iPageCurrent
| > >
| > > ' Start output with a page x of n line
| > > %>
| > > <p>
| > > <font size="+1">Record <strong><%= iPageCurrent %></strong>
| > > of <strong><%= iPageCount %></strong></font>
| > > </p>
| > > <%
| > > ' Spacing
| > > Response.Write vbCrLf
| > >
| > > ' Continue with a title row in our table
| > > Response.Write "<table border=""1"">" & vbCrLf
| > >
| > > ' Show field names in the top row
| > > Response.Write vbTab & "<tr>" & vbCrLf
| > > For I = 0 To objPagingRS.Fields.Count - 1
| > > Response.Write vbTab & vbTab & "<th>"
| > > Response.Write objPagingRS.Fields(I).Name
| > > Response.Write "</th>" & vbCrLf
| > > Next 'I
| > > Response.Write vbTab & "</tr>" & vbCrLf
| > >
| > > ' Loop through our records and ouput 1 row per record
| > > iRecordsShown = 0
| > > Do While iRecordsShown < iPageSize And Not objPagingRS.EOF
| > > Response.Write vbTab & "<tr>" & vbCrLf
| > > For I = 0 To objPagingRS.Fields.Count - 1
| > > Response.Write vbTab & vbTab & "<td>"
| > > Response.Write objPagingRS.Fields(I)
| > > Response.Write "</td>" & vbCrLf
| > > Next 'I
| > > Response.Write vbTab & "</tr>" & vbCrLf
| > >
| > > ' Increment the number of records we've shown
| > > iRecordsShown = iRecordsShown + 1
| > > ' Can't forget to move to the next record!
| > > objPagingRS.MoveNext
| > > Loop
| > >
| > > ' All done - close table
| > > Response.Write "</table>" & vbCrLf
| > > End If
| > >
| > > ' Close DB objects and free variables
| > > objPagingRS.Close
| > > Set objPagingRS = Nothing
| > > objPagingConn.Close
| > > Set objPagingConn = Nothing
| > >
| > >
| > > ' Show "previous" and "next" page links which pass the page to view
| > > ' and any parameters needed to rebuild the query. You could just as
| > > ' easily use a form but you'll need to change the lines that read
| > > ' the info back in at the top of the script.
| > > If iPageCurrent > 1 Then
| > > %>
| > > <a
| > > href="http://www.bellfield-barna.com/BIE/...-9000/optionopenorders4300100090001.asp?page=<%=
| > > iPageCurrent - 1 %>&order=<%= Server.URLEncode(strOrderBy) %>">[<<
| > > Prev]</a>
| > > <%
| > > End If
| > >
| > > ' You can also show page numbers:
| > > For I = 1 To iPageCount
| > > If I = iPageCurrent Then
| > > %>
| > > <%= I %>
| > > <%
| > > Else
| > > %>
| > > <a
| > > href="http://www.bellfield-barna.com/BIE/...-9000/optionopenorders4300100090001.asp?page=<%=
| > > I %>&order=<%= Server.URLEncode(strOrderBy) %>"><%= I %></a>
| > > <%
| > > End If
| > > Next 'I
| > >
| > > If iPageCurrent < iPageCount Then
| > > %>
| > > <a
| > > href="http://www.bellfield-barna.com/BIE/...-9000/optionopenorders4300100090001.asp?page=<%=
| > > iPageCurrent + 1 %>&order=<%= Server.URLEncode(strOrderBy) %>">[Next
| > > >>]</a>
| > > <%
| > > End If
| > >
| > > ' END RUNTIME CODE
| > > %>
| > >
| > >
| > >
| >
| >
| >
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

ASP & Html 1
ASP does not find the data 1
ASP/HTML 1
Sill ASP/Html problem 5
Form input type alignment 1
ASP Script to Send an email which generates into a HTML format 2
asp upload 0
database edit 1

Top