Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Arguments are of the wrong type Error


Message #1 by "Jon Kerr" <kerrjon@y...> on Thu, 3 Oct 2002 03:05:08
Can someone please help me, I have been strugling with this for a few 
days and my webhosting company insists it is me.  I need to update an 
access database.  Below is my code.  My connection works fine because the 
code below will read from the database provided I do not include the 
cursors adOpenDynamic or adLockOptimistic.  When I do insert the cursors 
I get the following error:

Error Type:
ADODB.Recordset (0x800A0BB9)
Arguments are of the wrong type, are out of acceptable range, or are in 
conflict with one another.

Here is my code:

Set Conn = Server.CreateObject("ADODB.Connection") 
Conn.Open "DSN=Survey" 
surveyRec = Server.CreateObject("ADODB.Recordset")
query = "Select * FROM Data"

'The line below works without the cursor types or with either of one
'them, but not with both.
'My main issue is that I have to be able to update this database.
'If I get rid of them both cursors and try to update to the database
'I get a recordset cannot fetch backwards error
'on the line below.

surveyRec.Open query, conn,  adOpenDynamic, adLockOptimistic, adCmdText

If Not surveyRec.EOF Then
	surveyRec.MoveLast
End If

'add survey to the database
surveyRec.AddNew
	surveyRec("fName") = fName
	surveyRec("lName") = lName
surveyRec.Update
surveyRec.Close

Anyone???  
Thanks,
Jon
Message #2 by "Ken Schaefer" <ken@a...> on Thu, 3 Oct 2002 12:01:33 +1000
Some tips:

www.adopenstatic.com/faq/800a0bb9.asp covers you situation as far as I can
tell. Using

<%
Option Explicit
%>

at the top of the page often catches these problems as well.

Secondly, you don't need .movelast to add a new record - why are you
scrolling through the entire recordset, just to add a new record? That's
really expensive.

Lastly, if you can avoid using cursors then you'll get far better
performance out of your database. Databases work best when you use sets of
data (ever used SQL? SQL works on set theory as well). In you case, you can
avoid generating a cursor altogether, just do:

<%
strSQL = _
    "INSERT INTO [Data] (fName, lName) " & _
    "VALUES ('" & fName & "', '" & lName & "')"

objConn.Execute strSQL
%>

no need for a recordset at all.

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Jon Kerr" <kerrjon@y...>
Subject: [asp_databases] Arguments are of the wrong type Error


: Can someone please help me, I have been strugling with this for a few
: days and my webhosting company insists it is me.  I need to update an
: access database.  Below is my code.  My connection works fine because the
: code below will read from the database provided I do not include the
: cursors adOpenDynamic or adLockOptimistic.  When I do insert the cursors
: I get the following error:
:
: Error Type:
: ADODB.Recordset (0x800A0BB9)
: Arguments are of the wrong type, are out of acceptable range, or are in
: conflict with one another.
:
: Here is my code:
:
: Set Conn = Server.CreateObject("ADODB.Connection")
: Conn.Open "DSN=Survey"
: surveyRec = Server.CreateObject("ADODB.Recordset")
: query = "Select * FROM Data"
:
: 'The line below works without the cursor types or with either of one
: 'them, but not with both.
: 'My main issue is that I have to be able to update this database.
: 'If I get rid of them both cursors and try to update to the database
: 'I get a recordset cannot fetch backwards error
: 'on the line below.
:
: surveyRec.Open query, conn,  adOpenDynamic, adLockOptimistic, adCmdText
:
: If Not surveyRec.EOF Then
: surveyRec.MoveLast
: End If
:
: 'add survey to the database
: surveyRec.AddNew
: surveyRec("fName") = fName
: surveyRec("lName") = lName
: surveyRec.Update
: surveyRec.Close
:
: Anyone???
: Thanks,


Message #3 by "Jon Kerr" <kerrjon@y...> on Thu, 3 Oct 2002 03:34:29
That is some good advice Ken.  I am familiar with update statements and I 
will try that.

Cheers to you,
Jon 

  Return to Index