Procedure or function RecordTxn has too many arguments specified

Discussion in 'ASP General' started by c676228, Sep 11, 2006.

  1. c676228

    c676228 Guest

    Hi everyone,
    I have a sql store procedure which accept three parameters and for the first
    time I call this store procedure, it seems fine, but when I call it second
    time in the program with the same code, it seems it memorizes the old three
    parameters I appended the first time and it gives me the error message as
    specified in the subject line. I just don't know how to avoid it.
    I need to call in the program for multiple times, any suggestions I should do?
    I just cannot think of a good way to do it.
    Thank you.
    Betty

    cmdTemp.CommandText = "RecordTxn"
    cmdTemp.CommandType = adCmdStoredProc
    Set paramOrderID=cmdTemp.CreateParameter("@orderID", adVarChar,
    adParamInput,26)
    Response.Write order_id
    'Response.End
    paramOrderID.value=order_id

    cmdTemp.Parameters.Append paramOrderID
    Set paramNo=cmdTemp.CreateParameter("@no", adChar, adParamInput,26)
    paramNo.value=trim(Request("number"))
    cmdTemp.Parameters.Append paramNo
    Set paramExpDate=cmdTemp.CreateParameter("@date", adChar, adParamInput,4)
    paramDate.value=str_date
    cmdTemp.parameters.Append paramDate
    cmdTemp.Execute
    --
    Betty
    c676228, Sep 11, 2006
    #1
    1. Advertising

  2. c676228 wrote:
    > Hi everyone,
    > I have a sql store procedure which accept three parameters and for
    > the first time I call this store procedure, it seems fine, but when I
    > call it second time in the program with the same code, it seems it
    > memorizes the old three parameters I appended the first time and it
    > gives me the error message as specified in the subject line. I just
    > don't know how to avoid it.
    > I need to call in the program for multiple times, any suggestions I
    > should do? I just cannot think of a good way to do it.
    > Thank you.
    > Betty
    >
    > cmdTemp.CommandText = "RecordTxn"
    > cmdTemp.CommandType = adCmdStoredProc
    > Set paramOrderID=cmdTemp.CreateParameter("@orderID", adVarChar,
    > adParamInput,26)
    > Response.Write order_id
    > 'Response.End
    > paramOrderID.value=order_id
    >
    > cmdTemp.Parameters.Append paramOrderID
    > Set paramNo=cmdTemp.CreateParameter("@no", adChar, adParamInput,26)
    > paramNo.value=trim(Request("number"))


    Always validate user inputs before using them!

    > cmdTemp.Parameters.Append paramNo
    > Set paramExpDate=cmdTemp.CreateParameter("@date", adChar,


    Why are you storing a date in a Char field rather than a datetime field?

    > adParamInput,4) paramDate.value=str_date
    > cmdTemp.parameters.Append paramDate
    > cmdTemp.Execute


    Well, you have no output parameters, so I would suggest, instead of the
    explicit Command object, using the "procedure-as-connection-method"
    technique (see my previous reply for the link I posted.) In this case,
    assuming "conn" is the name of your connection variable:

    dim num
    num=trim(Request("number"))
    if not IsValid(num) then
    Response.Write num & " is not valid"
    Response.End
    end if
    conn.RecordTxn order_id, num, str_date

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Sep 11, 2006
    #2
    1. Advertising

  3. c676228

    c676228 Guest

    Re: Procedure or function RecordTxn has too many arguments specifi

    Thanks for your expert opinion, Bob.
    Yep, it works better to use your way. it also reduces the number of lines of
    code.
    str_date is just a string like '0708', not a real date.
    --
    Betty


    "Bob Barrows [MVP]" wrote:

    > c676228 wrote:
    > > Hi everyone,
    > > I have a sql store procedure which accept three parameters and for
    > > the first time I call this store procedure, it seems fine, but when I
    > > call it second time in the program with the same code, it seems it
    > > memorizes the old three parameters I appended the first time and it
    > > gives me the error message as specified in the subject line. I just
    > > don't know how to avoid it.
    > > I need to call in the program for multiple times, any suggestions I
    > > should do? I just cannot think of a good way to do it.
    > > Thank you.
    > > Betty
    > >
    > > cmdTemp.CommandText = "RecordTxn"
    > > cmdTemp.CommandType = adCmdStoredProc
    > > Set paramOrderID=cmdTemp.CreateParameter("@orderID", adVarChar,
    > > adParamInput,26)
    > > Response.Write order_id
    > > 'Response.End
    > > paramOrderID.value=order_id
    > >
    > > cmdTemp.Parameters.Append paramOrderID
    > > Set paramNo=cmdTemp.CreateParameter("@no", adChar, adParamInput,26)
    > > paramNo.value=trim(Request("number"))

    >
    > Always validate user inputs before using them!
    >
    > > cmdTemp.Parameters.Append paramNo
    > > Set paramExpDate=cmdTemp.CreateParameter("@date", adChar,

    >
    > Why are you storing a date in a Char field rather than a datetime field?
    >
    > > adParamInput,4) paramDate.value=str_date
    > > cmdTemp.parameters.Append paramDate
    > > cmdTemp.Execute

    >
    > Well, you have no output parameters, so I would suggest, instead of the
    > explicit Command object, using the "procedure-as-connection-method"
    > technique (see my previous reply for the link I posted.) In this case,
    > assuming "conn" is the name of your connection variable:
    >
    > dim num
    > num=trim(Request("number"))
    > if not IsValid(num) then
    > Response.Write num & " is not valid"
    > Response.End
    > end if
    > conn.RecordTxn order_id, num, str_date
    >
    > --
    > Microsoft MVP -- ASP/ASP.NET
    > Please reply to the newsgroup. The email account listed in my From
    > header is my spam trap, so I don't check it very often. You will get a
    > quicker response by posting to the newsgroup.
    >
    >
    >
    c676228, Sep 14, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike P
    Replies:
    0
    Views:
    3,295
    Mike P
    Jun 19, 2006
  2. Mike
    Replies:
    3
    Views:
    485
  3. David Lozzi
    Replies:
    0
    Views:
    686
    David Lozzi
    Mar 2, 2007
  4. Seth Williams
    Replies:
    1
    Views:
    568
    Seth Williams
    Sep 16, 2008
  5. John Smith

    Procedure or function has too many arguments specified

    John Smith, Jun 29, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    143
    John Smith
    Jun 29, 2005
Loading...

Share This Page