Parameter problem with VB Script

  • View a printable version of this message!Hi, I am writing a VB script class and using ADO with the parameters object to execute a stored procedure.

    I keep getting the message:

    [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure 'svme_aspAddXXX' expects parameter '@username', which was not supplied.

    I have used this code before and it works fine.  I am creating the parameter and then appending it to the command object.

    Does anyone have any ideas what the problem could be.

    Thanks in advance for any tips.

  • Would have to see the code to see where maybe you made a mistake.

     

  • Hi, Here is the code. I am stumped as to why it doesn't work.  Thanks for your help.

    Function Add ()

    Dim objConn

    Dim objSPCmd

    Dim paramUserName

    Dim paramFirstName

    Dim paramLastName

    ..more here

    Dim lngRecs

    On Error Resume Next

    set objConn=Server.CreateObject("ADODB.Connection")

    objConn.ConnectionString=STRCONNECT

    objConn.Open STRCONNECT

    Set objSPCmd=Server.CreateObject("ADODB.Command")

    Set objSPCmd.ActiveConnection = objConn

    objSPCmd.CommandText="svme_aspAddUser"

    Set paramUserName=objSPCmd.CreateParameter ("@username",adChar ,adParamInput ,15,username)

    Set paramFirstName=objSPCmd.CreateParameter("@firstname",adVarchar,adParamInput,50,firstname)

    Set paramLastName=objSPCmd.CreateParameter("@lastname",adVarchar,adParamInput,50,lastname)

    ...more here

    objSPCmd.Parameters.append paramUserName

    objSPCmd.Parameters.append paramFirstName

    objSPCmd.Parameters.append paramLastName

    objSPCmd.Execute lngRecs,,adExecuteNoRecords

    If Err.number<>0 then

    Response.Write "Error " & Err.number & " - " & Err.Description

    Add=false

    Else

    Add=true

    End if

    Set paramUserName=nothing

    Set paramFirstName=nothing

    Set paramLastName=nothing

    Set objSPCmd=nothing

    objConn.Close

    set objConn=nothing

    End function

  • Ok two things.

    1) Is @username the first parameter in yuor actuall stored procedure? If not can you post the header (the stuff before the opening AS) for us?

    2) Try setting the connection objects command type to adCmdStoreProc

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply