How do you open an ADODB.recordset using a ADODB.Command on stored procedure in ASP.NET???

I'm updating my 'classic' asp to aspx (what fun)

Perfectly good code doesn't work now e.g.

Dim cmd

cmd = Server.CreateObject("ADODB.Command")

Dim RS

RS = Server.CreateObject("ADODB.Recordset")

With cmd

.ActiveConnection = Con

.CommandText = "sp_CategoryTreeClimb"

.CommandType = 4

.Parameters.Append.CreateParameter("@ID", adInteger, adParamInput, , ID)

RS = .Execute

End With

If Not RS.EOF And Not RS.BOF Then etc....

I get the cryptic 'System.Reflection.TargetParameterCountException: Number of parameters specified does not match the expected number' error

They bloody did! They Bloody do!

What new wrinkle do I need to make it work



Answer this question

How do you open an ADODB.recordset using a ADODB.Command on stored procedure in ASP.NET???

  • Dan Sherwin

    The values going in are good (omitted for clarity)

    I've played about with the syntax and don't now get an error. Trouble is, I don't get a filled recordset either! It's EOF and BOF

    With cmd

    .ActiveConnection = Con

    .CommandText = "sp_CategoryTreeClimb"

    .CommandType = 4

    .Parameters.Append (.CreateParameter ("@ID",adInteger,adParamInput,,ID))

    RS = .Execute

    End With

    It's got to be something to do with RS = .Execute line

    This works fine on a .asp page but has SET RS = .Execute and SET 'is not supported' in aspx

    I've spent hours on this, so much for Microsoft support and user friendlyness!


  • igor_22

    I managed to fix it by ensuring no empty or null or non integer values got into the ID parameter

    Visual studio gave no helpful advice, errors were cryptic, and microsoft do not document this unusual behavior

    Typical!

    LOL


  • Andy Ho

    I hope the issue is with the parameters you are passing to the stored procedure. Is ID the only parameter in the stored procedure.

    Can you post the stored procedure here.



  • How do you open an ADODB.recordset using a ADODB.Command on stored procedure in ASP.NET???