how to call Stored Procedure in vb.net 2003

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ganeshvkl
    New Member
    • Jul 2008
    • 50

    #1

    how to call Stored Procedure in vb.net 2003

    hi ,
    I'm Trying to Call the Stored Procedure which has one input Parameter and one output parameter . VB.net code is below

    Code:
    dim C as int16 , A as int16 
    A = 5
           cmd = New SqlCommand("[Addition]", cn)
           cmd.CommandType = CommandType.StoredProcedure
    
                With sqlparam1
                    .ParameterName = "@A"
                    .SqlDbType = Int
                    .Value = A
                End With
    
                With sqlparam2
                    .ParameterName = "@B"
                    .SqlDbType = Int
                    .Direction = ParameterDirection.Output
                End With
    
                With cmd
                    .Parameters.Add(sqlparam1)
                    .Parameters.Add(sqlparam2)
                    .CommandType = CommandType.StoredProcedure
    
                     C  = CType(cmd.Parameters("@B").Value, Int16)
    I got result 0 instead of 7.

    Thanx in Adv
    Ganesh
    Last edited by PRR; Mar 23 '09, 09:38 AM. Reason: Please post code in [code] [/code] tags.
  • aryanbs
    New Member
    • Mar 2009
    • 42

    #2
    How did you execute? ExecuteNonQuery ?

    Try ExecuteScalar

    Comment

    • PRR
      Recognized Expert Contributor
      • Dec 2007
      • 750

      #3
      Take a look at Call SQL Server Stored Procedures in ASP.NET

      Comment

      Working...