Forum Moderators: open
Error Type:
ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/socoolbrew/testca.asp, line 38
The script is as follows: I would really value help as I have been on a no brainer with this for 2 days! have pity on me!
<%@LANGUAGE="VBSCRIPT"%>
<%
Option Explicit
Response.Expires = 0
%>
<!--#include file="adovbs.inc" -->
<%
Dim StrSearchtxt
StrSearchtxt = Request.Form("cool")
Const intPageSize = 5
Dim intCurrentPage, objConn, objRSa, strQ
Dim intTotalPages, intI
If Request.ServerVariables("CONTENT_LENGTH") = 0 Then
intCurrentPage = 1
Else
intCurrentPage = CInt(Request.Form("CurrentPage"))
Select Case Request.Form("Submit")
Case "Previous"
intCurrentPage = intCurrentPage - 1
Case "Next"
intCurrentPage = intCurrentPage + 1
End Select
End If
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.Open "DSN=brewster"
Set objRSa = Server.CreateObject("ADODB.RecordSet")
objRSa.CursorLocation = adUseClient
objRSa.CursorType = adOpenStatic
objRSa.CacheSize = intPageSize
strQ = "SELECT title, rating FROM review WHERE title = '" &StrSearchtxt & "'"
objRSa.Open strQ, objConn, , ,adCmdText <--ERROR POSS HERE?
objRSa.PageSize = intPageSize
If (Not objRSa.EOF) Then objRSa.AbsolutePage = intCurrentPage
intTotalPages = objRSa.PageCount
%>
And this IS embedded further into the script with some HTML
<%
For intI = 1 To objRSa.PageSize
Response.Write objRSa("title")
Response.Write objRSa("rating")
'Response.Write Server.HTMLEncode(objRS("title") & ":" & objRS("rating")) & "<BR>"
objRSa.MoveNext
If objRSa.EOF Then Exit For
Next
objRSa.Close : objConn.Close
Set objRSa = Nothing : Set objConn = Nothing
%>
<BR>
Page <%= intCurrentPage %> of <%= intTotalPages %><P><FORM ACTION="<%= Request.ServerVariables("SCRIPT_NAME") %>" METHOD="POST">
<INPUT TYPE="Hidden" Name="CurrentPage"
VALUE="<%= intCurrentPage%>">
<%If intCurrentPage > 1 Then %>
<INPUT TYPE="Submit" Name="Submit" VALUE="Previous">
<% End If
If intCurrentPage <> intTotalPages Then %>
<INPUT TYPE="Submit" NAME="Submit" VALUE="Next">
<% End If %>
</FORM>
If for example I replace the SQL statement with one like this: SELECT * FROM review
The script works fine. But if I use the script with the above SQL statment it doesnt and gives me that error.
Any other thoughts?
Then get back to us with what comes out. It may be that you have ticks in your StrSearchtxt variable, or that text could be too long. Many options here.
Let's take the first step and see exactly what SQL is executing(failing?).
SELECT title, rating FROM review WHERE title = 'terminator 3'
There is an entry in the database call for terminator 3 and the field for title in the Access database is a TEXT field with a maximum lenght of 50.
All I know up to know is if I remove this SQL statement and replace with one that doesnt accept a variable from a form the script works fine. It's real puzzle to me as I would of thought it would work.
Error Type:
ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/socoolbrew/testca.asp, line 36
Line 36 in my code is:
If (Not objRSa.EOF) Then objRSa.AbsolutePage = intCurrentPage
Any further ideas guys? I am sure I have done something really stupid but cant seem to put my finger on it.
Error Type:
ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
/socoolbrew/testca.asp, line 37
SELECT title FROM review
All the the paging code works fine, but as soon as I replace the simplay SQL statement with the one I am attempting to use it causes errors?
I'm sure I am doing something stupid but I can't workout what? LOL
How else might I attempt paging using Access?
I have got all the other pages for this site working using classic ASP and this is the only page I cant get to work :-(
I think the problem lies with the text from your request.form consisting of 'text-space-number'
it's therefore neither a string or an integral.
May I suggest to try my previous posted "Select.... " again
and change at the top of your page :
StrSearchtxt = Request.Form("cool")
to
StrSearchtxt = Server.HTMLEncode(Request.Form("cool"))
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'title ='.
/socoolbrew/testd.asp, line 33
This script is turning into my worst nightmare! LOL
Error Type:
Microsoft VBScript compilation (0x800A0409)
Unterminated string constant
/socoolbrew/testd.asp, line 32, column 75
strQ = "SELECT title, rating FROM review WHERE title = " & StrSearchtxt & "
--------------------------------------------------------------------------^
I think I might have to give up guys and maybe start a new script from the start and see if I get lucky.
I can now get the script to execute statment based on an variable requested from a form. But on loading it as soon as I click the next page link to view further records I get the following message:
Error Type:
ADODB.Recordset (0x800A0BCD)
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
/socoolbrew/testcab.asp, line 61
Line 61 being: rsData.AbsolutePage = intPage
Having spent a few hours on this script I really thought I had it this time! LOL
The new code is as follows:
<%@LANGUAGE="VBSCRIPT"%>
<html><title></title>
<%
'Option Explicit
Response.Expires = 0
%>
<!--#include file="adovbs.inc" -->
<%
Dim StrSearchtxt
StrSearchtxt = Request.Form("cool") ' Get text to define SQL filter search
Dim rsData
Dim intPage
Dim intTotalPages
Dim fldF
Dim intRec
Dim strQuote
Dim strScriptName
Dim StrQ
Dim StrConn
StrQuote = Chr(34) ' The double quote character
'Set objConn = Server.CreateObject("ADODB.Connection")
'objConn.Open "DSN=brewster"
Set rsData = Server.CreateObject("ADODB.Recordset")
' Setting the page size
rsData.PageSize = 5
rsData.CursorLocation = adUseClient
' Define connection string to database
StrConn = "DSN=brewster"
' Open the recordset and define SQL statement
strQ = "SELECT * FROM review WHERE title = '" & StrSearchtxt & "'"
rsData.Open StrQ, strConn, adOpenForwardOnly, adLockReadOnly, adCmdText
%>
<body>
<%
If Request.QueryString("PAGE") = "" Then
intPage = 1
Else
' Protect against out of range pages, in case of a user specified page number
If intPage < 1 Then
intPage = 1
Else
If intPage > rsData.PageCount Then
intPage = rsData.PageCount
Else
intPage = CInt (Request.QueryString("PAGE"))
End If
End If
End If
' Set the absolute page number to the requested page
rsData.AbsolutePage = intPage
' Start building the table
Response.Write "<TABLE BORDER=1><THEAD<TR>"
For Each fldF In rsData.Fields
Response.Write "<TD>" & fldF.Name & "</TD>"
Next
Response.Write "</TR></THEAD><TBODY>"
'Looping through
For intRec = 1 To rsData.PageSize
If Not rsData.EOF Then
Response.Write "<TR>"
For Each fldF In rsData.Fields
Response.Write "<TD>" & fldF.Value & "</TD>"
Next
Response.Write "</TR>"
rsData.MoveNext
End If
Next
Response.Write "</TBODY></THEAD></TABLE><P>"
'Now some paging controls
strScriptName = Request.ServerVariables("SCRIPT_NAME")
Response.Write " <A HREF= " & strQuote & strScriptName & "?PAGE=1" & strQuote & ">First Page</A>"
'Only give an active previous page if there are previous pages
If intPage = 1 Then
Response.Write " <SPAN>Previous Page</SPAN>"
Else
Response.Write " <A HREF=" & strQuote & strScriptName & "?PAGE=" & intPage - 1 & strQuote & ">Previous Page</A>"
End If
'Only give an active next page if there are more pages
If intPage = rsData.PageCount Then
Response.Write " <SPAN>Next Page</SPAN>"
Else
Response.Write " <A HREF=" & strQuote & strScriptName & "?PAGE=" & intPage + 1 & strQuote & ">Next Page</A>"
End If
Response.Write " <A HREF=" & strQuote & strScriptName & "?PAGE=" & rsData.PageCount & strQuote & ">Last Page</A>"
' Dispose of all objects & connections
rsData.Close
Set rsData = Nothing
%>
</html>
Basicly my problem is that I am in ASP.NET mode at the moment and am in the process of developing a website at work. In my own time have been developing a free movie website called socoolbrewster.com which the above code is from using classic ASP.
While I think about any you guys know the best place to get a site SUBMITTED free of charge to many of the leading search engines like Google, MSN etc... And have them submitted ASAP?
Also another problem I have had is when a user submits a review using a form if they include a ' or " characters it causes my INSERT SQL statment into an error Anyway I can work round this?
Cheers for all the help guys really appreciate it
<%@LANGUAGE="VBSCRIPT"%>
<html><title></title>
<%
'Option Explicit
'Response.Expires = 0
%>
<!--#include file="adovbs.inc" -->
<%
Dim StrSearchtxt
StrSearchtxt = Request.Form("cool") ' Get text to define SQL filter search
'Should a user try and submit a blank field for a search
If StrSearchtxt = "" Then
Response.Redirect("index.html")
End If
Dim rsData
Dim intPage
Dim intTotalPages
Dim fldF
Dim intRec
Dim strQuote
Dim strScriptName
Dim StrQ
Dim StrConn
StrQuote = Chr(34) ' The double quote character
Set rsData = Server.CreateObject("ADODB.Recordset")
' Setting the page size
rsData.PageSize = 10
rsData.CursorLocation = adUseClient
' Define connection string to database
StrConn = "DSN=brewster"
' Open the recordset and define SQL statement
strQ = "SELECT * FROM review WHERE title = '" & StrSearchtxt & "'"
rsData.Open StrQ, strConn, 3, 1
%>
<%
' Count how many records obtained from database if 0 then redirect script to prevent error
Dim strRecordsCount
strRecordsCount = rsData.RecordCount
If strRecordsCount = 0 Then
rsData.Close
Set rsData = Nothing
Response.Redirect("index.html")
End If
%>
<body>
<%
If Request.QueryString("PAGE") = "" Then
intPage = 1
Else
' Protect against out of range pages, in case of a user specified page number
If intPage < 1 Then
intPage = 1
Else
If intPage > rsData.PageCount Then
intPage = rsData.PageCount
Else
intPage = CInt(Request.QueryString("PAGE"))
End If
End If
End If
' Set the absolute page number to the requested page
rsData.AbsolutePage = intPage
' Start building the table
Response.Write "<TABLE BORDER=1><THEAD<TR>"
For Each fldF In rsData.Fields
Response.Write "<TD>" & fldF.Name & "</TD>"
Next
Response.Write "</TR></THEAD><TBODY>"
'Looping through
For intRec = 1 To rsData.PageSize
If Not rsData.EOF Then
Response.Write "<TR>"
For Each fldF In rsData.Fields
Response.Write "<TD>" & fldF.Value & "</TD>"
Next
Response.Write "</TR>"
rsData.MoveNext
End If
Next
Response.Write "</TBODY></THEAD></TABLE><P>"
'Now some paging controls
strScriptName = Request.ServerVariables("SCRIPT_NAME")
Response.Write " <A HREF= " & strQuote & strScriptName & "?PAGE=1" & strQuote & ">First Page</A>"
'Only give an active previous page if there are previous pages
If intPage = 1 Then
Response.Write " <SPAN>Previous Page</SPAN>"
Else
Response.Write " <A HREF=" & strQuote & strScriptName & "?PAGE=" & intPage - 1 & strQuote & ">Previous Page</A>"
End If
'Only give an active next page if there are more pages
If intPage = rsData.PageCount Then
Response.Write " <SPAN>Next Page</SPAN>"
Else
Response.Write " <A HREF=" & strQuote & strScriptName & "?PAGE=" & intPage + 1 & strQuote & ">Next Page</A>"
End If
Response.Write " <A HREF=" & strQuote & strScriptName & "?PAGE=" & rsData.PageCount & strQuote & ">Last Page</A>"
' Dispose of all objects & connections
rsData.Close
Set rsData = Nothing
%>
</html>