Error ADODB.Recordset '800a0bb9': arguments of the wrong type

Set rsPlanID = Server.CreateObject("ADODB.Recordset")
rsPlanID.CursorLocation = adUseClient

strSQL = "SELECT PlanID FROM ATTJournals WHERE ATTUserDataID = " & ATTUserDataID 
rsPlanID.Open strSQL, m_objConn, adOpenStatic, adLockOptimistic

If Not rsPlanID.EOF Then
    response.Write "New PlanID:"  & rsPlanID("PlanID")
End If

The above code is in classic asp.

I get the following error:

Error ADODB.Recordset '800a0bb9' The
arguments are of the wrong type, are out of range, or are in conflict with each other.

Does anyone know the cause of this error and how to fix it?

+5
source share
5 answers

The most important reason is that you did not include "ADOVBS.INC" or equavalent META: -

<!--METADATA
TYPE="TypeLib"
NAME="Microsoft ActiveX Data Objects 2.6 Library"
UUID="{00000206-0000-0010-8000-00AA006D2EA4}"
VERSION="2.6"
-->

Therefore, constants adxxxxdo not exist. However, your main mistake does not include Option Explicitat the top of your script. This will save you from unnecessary loads of time, hunting for stupid mistakes and typos.

BTW , ATTUserDataID "0; DELETE ATTJournals;"?
SQL , . "ASP SQL Injection", .

+14

-, vbscript, . :

rsPlanID.Open strSQL, m_objConn, 3, 3

, adovbs.inc. . .

-, ,

rsPlanID.CursorLocation = adUseClient 

Thrird, . . , .

0

, :

strSQL = "SELECT PlanID FROM ATTJournals WHERE ATTUserDataID = " & ATTUserDataID 
Set rsPlanID = m_objConn.Execute(strSQL)

, SQL Injection - .

0

It seems to me that I searched the entire Internet and could not find a solution to this problem, and just as I was about to give up, I realized that I declared my connection variable in the expression "If" and because if did not execute my command in database, indicating an error as indicated in your question.

0
source
Function SQL_getRecordset(strQuery)

'On Error Resume Next
 'Create Database connection object
  Set objConnection = CreateObject("ADODB.Connection")

  'Create Recordset object
  Set objrecordset = CreateObject("ADODB.Recordset")

  'Specify the connection string
  strConnectionstring = "Provider=SQLOLEDB.1;Data Source=*<Server name>*;Initial Catalog=*<database>*;Integrated Security=SSPI"
  objConnection.Open strConnectionstring

  'Execute the Query
  Set objrecordset = objConnection.Execute(strQuery)

  'Return Recordset
  Set SQL_getRecordset = objrecordset

  'Release objects from the memory
  Set objConnection = Nothing
  Set objrecordset = Nothing

End Function
-1
source

All Articles