Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ADODB.Recordset error '800a0bb9' : Arguments are of the wrong type

Tags:

asp-classic

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 am getting the following error:

ADODB.Recordset error '800a0bb9'
Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

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

like image 498
Jagadeesh Avatar asked Dec 08 '11 09:12

Jagadeesh


2 Answers

The most like cause is that you haven't included "ADOVBS.INC" or the equavalent META:-

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

Hence the adxxxx constants do not exist. However your primary mistake is not including Option Explicit at the top your script. This will save you bucket loads of time hunting silly mistakes and typos.

BTW What happens if ATTUserDataID contained "0; DELETE ATTJournals;" ?
Avoid composing SQL using concatenation like the plague. Search for "ASP SQL Injection" to find examples of using parameterised command objects instead.

like image 152
AnthonyWJones Avatar answered Oct 17 '22 02:10

AnthonyWJones


Unless you need to navigate back and forth in the recordset, just use the default settings:

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

Also, your code is wide open for SQL Injection attacks - you better learn about it and change your code to use Parameters instead.

like image 23
Shadow Wizard Hates Omicron Avatar answered Oct 17 '22 02:10

Shadow Wizard Hates Omicron