Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Paging problem?

Status
Not open for further replies.

Gill1978

Programmer
Jun 12, 2001
277
GB
Hi!

I've tried adding paging code to my asp file, so that is brings back 10 records per page. However, i've come across a problem with page - I get the following error ;

Error Type:
Microsoft VBScript compilation (0x800A03EA)
Syntax error
/Miller_Local/Test.asp, line 65, column 78
response.write &quot;<a href=&quot;&quot;test.asp?sqlQuery=&quot; & request.querystring(&quot;Query&quot;) &
-----------------------------------------------------------------------------^

Can anyone see what i'm doing wrong (I've only just started using ASP).

The asp page code is:

<%@ Language=VBScript %>
<% ' Response.buffer = false %>
<html>
<link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;stylesheets/Application.css&quot;>
<head>
<!--#INCLUDE FILE=&quot;codeblocks/db.asp&quot;-->
<!--#INCLUDE FILE=&quot;codeblocks/HoverOver.htm&quot;-->
</head>
<body topMargin=&quot;0&quot; leftMargin=&quot;0&quot; rightMargin=&quot;0&quot; bottomMargin=&quot;0&quot;>
<!--#INCLUDE FILE=&quot;codeblocks/pageheader.htm&quot;-->
<table border=&quot;0&quot; cellSpacing=&quot;0&quot; cellPadding=&quot;0&quot; width=&quot;100%&quot;>
<thead>
<tr height=&quot;28&quot;><td class=&quot;header&quot; COLSPAN=&quot;4&quot; style=&quot;font-size: 18&quot;>Contracts</td></tr>
<tr height=&quot;12&quot;>
<td style=&quot;width: 100&quot;>Contract</td>
<td>Description</td>
<td style=&quot;width: 40&quot;>Year</td>
<td style=&quot;width: 80&quot;>Agent</td>
</tr>
</thead>
<% dim oRS, i
set oRS = OpenDBQuery(&quot;Select top 250 * From Contract&quot;)
dim currentpage, a, pagenumber
If isempty(Request.Querystring(&quot;PageNumber&quot;)) then
CurrentPage =1
else
currentPage = Cint(Request.Querystring(&quot;PageNumber&quot;))
end if
response.write &quot;Page &quot; & currentpage
if oRS.EOF or oRS.BOF then
%><br>
<font size=&quot;2&quot; color=&quot;#ff0000&quot;>
<%
response.write &quot;Please choose an item from the list then click 'GO'&quot;
%>
</font>
<%
else

oRS.pagesize = 10
oRS.absolutepage = currentpage

do until oRS.absolutepage <> currentpage or oRS.EOF


%>
<%
i=0
while not oRS.EOF %>
<tr class=&quot;TR<%=((i mod 2)+1)%>&quot; style=&quot;height: 17px&quot;
onClick=&quot;window.location.href='Test2.asp?Contract=<%=Server.URLEncode(oRS.Fields(&quot;bindno&quot;))%>&Year=<%=oRS.Fields(&quot;bindyr&quot;)%>'&quot;
onMouseOver=&quot;Javascript:SelectionHoverOver(this,true);&quot;
onMouseOut=&quot;Javascript:SelectionHoverOut(this,<%=((i mod 2)+1)%>);&quot;>
<td><%=oRS.Fields(&quot;bindno&quot;)%></td>
<td><%=oRS.Fields(&quot;binddesc&quot;)%></td>
<td><%=oRS.Fields(&quot;bindyr&quot;)%></td>
<td><%=oRS.Fields(&quot;Agent&quot;)%></td>
</tr>
<% i=i+1
oRS.MoveNext

wend
response.write &quot;select page to view more distributors:&quot;
For i = 1 to oRS.pagecount
response.write &quot;<a href=&quot;&quot;test.asp?sqlQuery=&quot; & request.querystring(&quot;Query&quot;) &
&quot;&PageNumber=&quot; & i & &quot;&quot;&quot;>&quot; & i & &quot; </a>&quot;
next
oRS.close
set oRS = nothing
%>
</table>
<!--INCLUDE FILE=&quot;codeblocks/pagefooter.htm&quot;-->
</body>
</html>

Thankyou,

Julie
 
I've managed to fix the above problem but now i get a new error as follows:

Error Type:
Microsoft VBScript compilation (0x800A03EA)
Syntax error
/Miller_Local/codeblocks/db.asp, line 3, column 7
Public Function OpenDBConnection
------^


This worked fine before i put the paging code in. Do i need to put connection string values etc in? And if so how do i do that?

The function that the above calls for is in another file and contains the following:

<SCRIPT LANGUAGE=&quot;VBSCRIPT&quot; RUNAT=&quot;SERVER&quot;>

Public Function OpenDBConnection
Dim oConn
Set oConn = Server.CreateObject(&quot;ADODB.Connection&quot;)
oConn.ConnectionString = &quot;Driver = SQLServer; TrustedConnection = true; Server=&quot; & Application.Contents(&quot;DBServer&quot;)
oConn.Open
Set OpenDBConnection = oConn

End Function


Function OpenDBQuery(sSQL)

dim oRS
set oRS = Server.CreateObject(&quot;ADODB.Recordset&quot;)
oRS.Open sSQL, &quot; driver={SQL Server}; server=&quot; & Application.Contents(&quot;DBServer&quot;) & &quot;,1433 ; database=nastats; network=dbmsscon; TrustedConnection=true&quot;,1
Set OpenDBQuery = oRS

End Function


</SCRIPT>

Can anyone help???????

Thanks

Julie
 
Try removing the word 'Public' from the Function name.
To err is human, but to really foul things up requires a computer.
- Farmers' Almanac, 1978

 
try adding some empty parens after function name, or just make it a sub


Public Function OpenDBConnection()

or

Sub OpenDBConnection
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top