-3

I am working on a classic ASP web application In that I have a requirement of inserting 100 records (no. of records may change it depends on particular user selection). For this I am using parameterized query and prepared statement my code is as follows:

Set objComm2=Server.CreateObject("ADODB.Command")
objComm2.ActiveConnection=stConnect 
objComm2.Prepared=true
objComm2.CommanText="insert into trader(RegistrationID,SalesID) values (?,?)"
objComm2.Parameters.Append objComm2.CreateParameter("@RegistrationID", adInteger, adParamInput)
objComm2.Parameters.Append objComm2.CreateParameter("@SalesID", adInteger, adParamInput) 

while NOT objSel.EOF
  objComm2("RegistrationID") = Session("RegistrationID") 
  objComm2("SalesID") = objSel("SalesInventoryID")
  objComm2.Execute
  objSel.MoveNext
wend

Here stConnect contains connection variables defind in my project web config file, objSel(its a record set object) contains required data to supply for insert operation.

Now my problem is when I am running this code I am getting the following error in appending parameters to command object:

Parameter object is improperly defined. Inconsistent or incomplete information
was provided.

I couldn't find any error in my code.

user692942
  • 16,398
  • 7
  • 76
  • 175
kaleshanagineni
  • 325
  • 1
  • 4
  • 13

1 Answers1

1

I suspect you didn't define the constants adInteger and adParamInput.

Evidence:

>> Set oCmd = CreateObject("ADODB.Command")
>> oCmd.CreateParameter "@RegistrationID", adInteger, adParamInput
>>
Error Number:       3001
Error Description:  Arguments are of the wrong type, are out of acceptable range, or are in conflict with one
another.

but:

>> Const adInteger          =          3
>> Const adParamInput       =          1
>> Set oCmd = CreateObject("ADODB.Command")
>> oCmd.CreateParameter "@RegistrationID", adInteger, adParamInput
>>
>> <-- no news are good news.

Update wrt comment:

VBScript knows nothing about ad*, xl*, or wd* constants. If you don't include a file like adovbs.inc or define them yourself (Const adInteger = 3, ...) - and don't use Option Explicit to catch such errors - they are just Empty.

Ekkehard.Horner
  • 38,498
  • 2
  • 45
  • 96
  • Do i need to define adInteger and adParamInput ? According to my knowledge adInteger is dbType and adParamInput species parameter direction in this case its a input – kaleshanagineni Jul 15 '15 at 21:24
  • thanks for your help i got it know – kaleshanagineni Jul 15 '15 at 21:48
  • @kaleshanagineni I wouldn't advise declaring these manually. [Using METADATA to Import DLL Constants](http://www.4guysfromrolla.com/webtech/110199-1.shtml) set this once in your `global.asa` file and your good to go for the rest of the web application. Haven't used `adovbs.inc` or `adovbs.asp` for years, it's just pointless. Using METADATA is far cleaner and less maintenance. – user692942 Jul 16 '15 at 14:31
  • @kaleshanagineni [ASP 3.0 Declare ADO Constants w/out Including ADOVBS.inc](http://stackoverflow.com/q/5145607/692942) – user692942 Jul 16 '15 at 14:40
  • thanks a lot for everyone for your answers. – kaleshanagineni Jul 16 '15 at 18:50