Read ouput parameters from stored procedure.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jared Grant
    New Member
    • Aug 2007
    • 3

    Read ouput parameters from stored procedure.

    I am trying to find the value from some output parameters from a stored procedure. I have tried several different methods but somehow cannot get it to work. here is my source code:

    dim dr as ODBCDataReader
    Dim comm as New ODBCCommand("{c all jgrant_awcconne ct..edit_equipm ent (?, ?, ?, ?, ?, ?)}", conn)

    comm.parameters .add("@equipmen tId", System.Data.Sql DbType.bigint)
    comm.parameters ("@equipmentId" ).Direction = ParameterDirect ion.Input
    comm.parameters ("@equipmentId" ).value = CInt(session("E quipmentId"))
    comm.parameters .add("@Short", System.Data.Sql DbType.Nvarchar )
    comm.parameters ("@Short").s ize = 20
    comm.parameters ("@Short").Dire ction = ParameterDirect ion.Output
    comm.parameters .add("@Long", System.Data.Sql DbType.Nvarchar )
    comm.parameters ("@Long").si ze = 50
    comm.parameters ("@Long").Direc tion = ParameterDirect ion.Output
    comm.parameters .add("@Owned", System.Data.Sql DbType.Nvarchar )
    comm.parameters ("@Owned").s ize = 3
    comm.parameters ("@Owned").Dire ction = ParameterDirect ion.Output
    comm.parameters .add("@Job_Pric e", System.Data.Sql DbType.money)
    comm.parameters ("@Job_Price"). Direction = ParameterDirect ion.Output
    comm.parameters .add("@Job_Cost ", System.Data.Sql DbType.money)
    comm.parameters ("@Long").Direc tion = ParameterDirect ion.Output
    conn.open()

    dr = comm.executerea der()
    dr.close
    conn.close()
    txtShort.text = comm.parameters ("@Owned").valu e
    txtLong.text = comm.parameters ("@Owned").valu e

    This code doesnt generate any errors but also does not display the right value. Anybody have any thoughts?
  • jigsmshah
    New Member
    • Aug 2007
    • 14

    #2
    try to use 'ParameterDirec tion.ReturnValu e' rather than output
    what ever value you return from stored procedure will be available in this returnValue in the front end
    For better ubderstanding please refer the following link
    http://www.mcse.ms/message1454145. html

    Regards
    Jignesh

    Comment

    • Jared Grant
      New Member
      • Aug 2007
      • 3

      #3
      I am trying to read the parameters not the return value. But good tip, I will use that in the future.

      Comment

      Working...