Getting Values from Stored Procedure

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rrocket
    New Member
    • Aug 2007
    • 116

    Getting Values from Stored Procedure

    I currently have this that sends a value to the DB and should return the information I need:

    [code=sql]Set RS = createobject("A DODB.Connection ")
    Set x1 = server.CreateOb ject("ADODB.Com mand")
    With x1
    .ActiveConnecti on = gObjConnect
    .CommandType = adCmdStoredProc
    .CommandText = "s_FRCWP_OpenSP InvoiceList"
    .Parameters.App end .CreateParamete r("@DirectoryId ", adInteger,adPar amInput,,94)
    .Execute
    End With[/code]

    But when I try to get the value with something like this:
    [code=asp]formString = formString & "<td><input type=""checkbox "" value="""&RS("T ransaction_ID") &"""></td>"[/code]

    I get a "Wrong number of arguments or invalid property assignment" error. Now I know I am not doing something right, but I cannot figure out what it is. Any help would be appreciated.
  • rrocket
    New Member
    • Aug 2007
    • 116

    #2
    I actually got it to return one row when I changed the "Set RS = createobject("A DODB.Connection ")" to "Set RS = createobject("A DODB.Recordset" )", but it gives me an error when I check for EOF try to use RS.MoveNext... Any ideas on how to get it to work?

    Comment

    • DrBunchman
      Recognized Expert Contributor
      • Jan 2008
      • 979

      #3
      Hi rrocket,

      Are you trying to return a record set from the database or just a single return value from the stored procedure?

      If you're using the record set then you have created a record set object but not assigned anything to it (which is why using RS("Transaction _ID") won't work).

      If you are just returning a single value then this needs to be the first item in your parameter list and it needs to have a parameter type of adParamReturnVa lue.

      Take a look at this. It's got some good examples and explanations of stored procedures which should give you enough info to fix your code.

      If you need any more help then let me know.

      Dr B

      Comment

      • rrocket
        New Member
        • Aug 2007
        • 116

        #4
        Thanks for your help... I actually changed the RS value to "Set RS = server.createob ject("ADODB.Rec ordset")", but keep getting an error when I try to use MoveNext, EOF, or BOF.... I am trying to return a list of things and am currently getting the first record, but that is it.

        Here is the error:
        Microsoft VBScript runtime error '800a01b6'

        Object doesn't support this property or method: 'MoveNext'

        I have been searching for a solution and have not been able to find anything.
        Last edited by rrocket; Apr 15 '08, 06:07 PM. Reason: Added the error

        Comment

        • rrocket
          New Member
          • Aug 2007
          • 116

          #5
          I finally figured it out... I commented the changes below.

          Here is the problem section:
          [code=asp]
          Set x1 = server.CreateOb ject("ADODB.Com mand")
          'Set RS = server.CreateOb ject("ADODB.Rec ordset") 'commented out and made change below
          With x1
          .ActiveConnecti on = gObjConnect
          .CommandType = adCmdStoredProc
          .CommandText = "StoredProcName "
          .Parameters.App end .CreateParamete r("@Customer_ID ", adInteger,adPar amInput,,sessio n("UserLocation Id"))
          set RS = .Execute 'Was RS = .Execute
          End With
          [/code]

          Comment

          Working...