0

I am getting the following Error in this parameterized query using Classic ASP.

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

Error is coming on this line cmd.CommandType = adCmdText

Dim requestedID
requestedID = Request("ID")

Dim requestedName
requestedName = Request("Name")

''' Create a parameterized SQL query
Dim strSQL
strSQL = "SELECT * FROM customer WHERE (ID = ?) AND (Name= ?)"

''' Create a Command object
Dim cmd
Set cmd = Server.CreateObject("ADODB.Command")
Set cmd.ActiveConnection = conn
cmd.CommandText = strSQL
cmd.CommandType = adCmdText

''' Create parameter objects and add them to the command
Dim paramID, paramName 
Set paramID = cmd.CreateParameter("@ID", adInteger, adParamInput,  , requestedID)
Set paramName = cmd.CreateParameter("@Name", adVarChar, adParamInput, 200, requestedName)

''' Add parameters to the command.

cmd.Parameters.Append paramID
cmd.Parameters.Append paramName 

''' Execute the query
Dim rs
Set rs = cmd.Execute

Compo
  • 36,585
  • 5
  • 27
  • 39
Babar
  • 75
  • 1
  • 7
  • 1
    What DBMS are you using? Are you using OLE-DB, ODBC, or another ADO provider? (This is relevant because not all providers support named vs. positional parameters). – Dai Sep 01 '23 at 09:10
  • Have you imported the ADODB Named Constants or using ADOVBS.INC? - [ASP 3.0 Declare ADO Constants w/out Including ADOVBS.inc](https://stackoverflow.com/a/5146495). Without either of these VBScript will not know what `adCmdText` is. – user692942 Sep 01 '23 at 09:49
  • I am using sql express database. I have added windows ADO file link in global.asa file. – Babar Sep 01 '23 at 14:14
  • It seems to work now, thank you for the help. – Babar Sep 02 '23 at 10:09

0 Answers0