sazer@mediaone.net

Results 1 to 3 of 3

Thread: sazer@mediaone.net

  1. #1
    Marc Sazer Guest

    Default sazer@mediaone.net

    Help!<BR>I&#039m trying to page through a result set; I know this is well-covered territory, but I&#039m a newbie and can&#039t get it to work. The initial query works fine; brings up the first page of results with the correct "page x of y" and "next" link. But the next page gives an error "incorrect "WHERE" clause".<BR>My script follows:<BR><BR>&#060;!--#INCLUDE FILE="ADOVBS.asp"--&#062;<BR>&#060;!--#INCLUDE FILE="dirheadinclude2.asp"--&#062;<BR><BR><BR>&#060;%<BR><BR>Const NumPerPage = 5<BR>Dim CurPage<BR>If Request.QueryString("CurPage") = "" then<BR> CurPage = 1<BR>Else<BR> CurPage = Request.QueryString("CurPage")<BR>End If<BR><BR>Dim objConn<BR>Set objConn = Server.CreateObject("ADODB.Connection")<BR>objConn .Open "DSN=xxxx; password=zzzzzz;"<BR><BR>Dim objRS, WhereClause, strSQL<BR>Dim Last, First, Professional<BR>Dim NoResults<BR><BR><BR>Last = Trim(Request("Last"))<BR>First = Trim(Request("First"))<BR>Professional = Trim(Request("Professional"))<BR><BR><BR>WhereClau se = "WHERE "<BR>If Last &#060;&#062; "" Then<BR> WhereClause = WhereClause & "LASTNAME LIKE &#039" & Last & "%&#039 AND "<BR>End If<BR><BR>If First &#060;&#062; "" Then<BR> WhereClause = WhereClause & "FIRSTNAME LIKE &#039" & First & "%&#039 AND "<BR>End If<BR><BR>If Professional &#060;&#062; "" Then<BR> WhereClause = WhereClause & "PROFNAME LIKE &#039"& Professional & "%&#039 AND "<BR>End If<BR><BR>If Right(WhereClause,4) = "AND " Then<BR> WhereClause = Left(WhereClause, Len(WhereClause) -4)<BR>End If<BR><BR>set objRS = Server.CreateObject("ADODB.Recordset")<BR>objRS.Cu rsorLocation = adUseClient<BR>objRS.CacheSize = NumPerPage<BR><BR>strSQL = "SELECT * FROM members " & WhereClause<BR><BR>objRS.Open strSQL, objConn<BR> <BR><BR>objRS.MoveFirst<BR>objRS.PageSize = NumPerPage<BR>Dim TotalPages<BR>TotalPages = objRS.PageCount<BR>objRS.AbsolutePage = CurPage<BR>Dim Count<BR><BR>Count = 0<BR><BR>NoResults = True<BR>Do While Not objRS.EOF and Count &#060; objRS.PageSize<BR> NoResults = False<BR><BR>Response.Write "&#060;font face=""tahoma,arial"" size=2&#062;&#060;strong&#062;" & objRS("LastName") & "&#060;/strong&#062;" & ", " <BR>Response.Write "&#060;font face=""tahoma,arial"" size=2&#062;" & objRS("FirstName")& " "<BR>Response.Write " " & objRS("ProfName") <BR>Response.Write "......" & objRS("Inst") <BR>Response.Write "<BR>Phone " & objRS("Phone1") <BR>Response.Write " " & objRS("Phone2") <BR>Response.Write " " & objRS("Phone3")<BR>Response.Write "<BR>Service " & objRS("Service") <BR>Response.Write "<BR>Pager " & objRS("Pager")& "<BR>" <BR>Response.Write "&#060;a href=mailto:" & objRS("Email") & "&#062;" & objRS("Email") & "&#060;/a&#062; <BR>" <BR>Response.Write "&#060;hr&#062;"<BR><BR>Count = Count + 1<BR>objRS.MoveNext <BR>Loop <BR><BR>Response.Write("Page " & CurPage & " of " & TotalPages & "&#060;P&#062;")<BR>If CurPage &#062; 1 then<BR>%&#062;<BR>&#060;a href="dirnew2.asp?curpage=&#060;%=(curpage - 1)%&#062;"&#062;Next&#060;/a&#062;<BR>&#060;%<BR>End If<BR><BR>If CInt(CurPage) &#060;&#062; CInt(TotalPages) then<BR>%&#062;<BR>&#060;a href="dirnew2.asp?curpage=&#060;%=(curpage + 1)%&#062;"&#062;Next&#060;/a&#062;<BR><BR>&#060;%<BR>End If<BR><BR>objRS.Close<BR>Set objRS = Nothing<BR>objConn.Close<BR>Set objConn = Nothing <BR><BR>If NoResults = True Then <BR>Response.Write "&#060;font face=""tahoma,arial"" size=2&#062;&#060;strong&#062;" & "Sorry, no records in the database matched your search parameters.<BR>"<BR>Response.Write "Please try again"<BR><BR>End If<BR>%&#062;<BR>

  2. #2
    Marc Sazer Guest

    Default RE: Oops! Need Paging Help

    Oops, I wrote the header wrong...<BR>Help!<BR>I&#039m trying to page through a result set; I know this is well-covered territory, but I&#039m a newbie and can&#039t get it to work. The initial query works fine; brings up the first page of results with the correct "page x of y" and "next" link. But the next page gives an error "incorrect "WHERE" clause".<BR>My script follows:<BR><BR>&#060;!--#INCLUDE FILE="ADOVBS.asp"--&#062;<BR>&#060;!--#INCLUDE FILE="dirheadinclude2.asp"--&#062;<BR><BR><BR>&#060;%<BR><BR>Const NumPerPage = 5<BR>Dim CurPage<BR>If Request.QueryString("CurPage") = "" then<BR>CurPage = 1<BR>Else<BR>CurPage = Request.QueryString("CurPage")<BR>End If<BR><BR>Dim objConn<BR>Set objConn = Server.CreateObject("ADODB.Connection")<BR>objConn .Open "DSN=xxxx; password=zzzzzz;"<BR><BR>Dim objRS, WhereClause, strSQL<BR>Dim Last, First, Professional<BR>Dim NoResults<BR><BR><BR>Last = Trim(Request("Last"))<BR>First = Trim(Request("First"))<BR>Professional = Trim(Request("Professional"))<BR><BR><BR>WhereClau se = "WHERE "<BR>If Last &#060;&#062; "" Then<BR>WhereClause = WhereClause & "LASTNAME LIKE &#039" & Last & "%&#039 AND "<BR>End If<BR><BR>If First &#060;&#062; "" Then<BR>WhereClause = WhereClause & "FIRSTNAME LIKE &#039" & First & "%&#039 AND "<BR>End If<BR><BR>If Professional &#060;&#062; "" Then<BR>WhereClause = WhereClause & "PROFNAME LIKE &#039"& Professional & "%&#039 AND "<BR>End If<BR><BR>If Right(WhereClause,4) = "AND " Then<BR>WhereClause = Left(WhereClause, Len(WhereClause) -4)<BR>End If<BR><BR>set objRS = Server.CreateObject("ADODB.Recordset")<BR>objRS.Cu rsorLocation = adUseClient<BR>objRS.CacheSize = NumPerPage<BR><BR>strSQL = "SELECT * FROM members " & WhereClause<BR><BR>objRS.Open strSQL, objConn<BR><BR><BR>objRS.MoveFirst<BR>objRS.PageSi ze = NumPerPage<BR>Dim TotalPages<BR>TotalPages = objRS.PageCount<BR>objRS.AbsolutePage = CurPage<BR>Dim Count<BR><BR>Count = 0<BR><BR>NoResults = True<BR>Do While Not objRS.EOF and Count &#060; objRS.PageSize<BR>NoResults = False<BR><BR>Response.Write "&#060;font face=""tahoma,arial"" size=2&#062;&#060;strong&#062;" & objRS("LastName") & "&#060;/strong&#062;" & ", " <BR>Response.Write "&#060;font face=""tahoma,arial"" size=2&#062;" & objRS("FirstName")& " "<BR>Response.Write " " & objRS("ProfName") <BR>Response.Write "......" & objRS("Inst") <BR>Response.Write "<BR>Phone " & objRS("Phone1") <BR>Response.Write " " & objRS("Phone2") <BR>Response.Write " " & objRS("Phone3")<BR>Response.Write "<BR>Service " & objRS("Service") <BR>Response.Write "<BR>Pager " & objRS("Pager")& "<BR>" <BR>Response.Write "&#060;a href=mailto:" & objRS("Email") & "&#062;" & objRS("Email") & "&#060;/a&#062; <BR>" <BR>Response.Write "&#060;hr&#062;"<BR><BR>Count = Count + 1<BR>objRS.MoveNext <BR>Loop <BR><BR>Response.Write("Page " & CurPage & " of " & TotalPages & "&#060;P&#062;")<BR>If CurPage &#062; 1 then<BR>%&#062;<BR>&#060;a href="dirnew2.asp?curpage=&#060;%=(curpage - 1)%&#062;"&#062;Next&#060;/a&#062;<BR>&#060;%<BR>End If<BR><BR>If CInt(CurPage) &#060;&#062; CInt(TotalPages) then<BR>%&#062;<BR>&#060;a href="dirnew2.asp?curpage=&#060;%=(curpage + 1)%&#062;"&#062;Next&#060;/a&#062;<BR><BR>&#060;%<BR>End If<BR><BR>objRS.Close<BR>Set objRS = Nothing<BR>objConn.Close<BR>Set objConn = Nothing <BR><BR>If NoResults = True Then <BR>Response.Write "&#060;font face=""tahoma,arial"" size=2&#062;&#060;strong&#062;" & "Sorry, no records in the database matched your search parameters.<BR>"<BR>Response.Write "Please try again"<BR><BR>End If<BR>%&#062;<BR>

  3. #3
    Join Date
    Dec 1969
    Posts
    34

    Default RE: Oops! Need Paging Help

    ok im new to this as well but have you looked at your where statements , how does it determine what path it is going to take the first time that it goes into this page ? <BR>The second time through the page it isnt being told what path to take so it cant create the sql statement. Does that make sense ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •