title: Getting response from a stored procedure
body: <p>Hey all i am looking to recieve a response back from the SP that i call out using VB.net. This is my code for doing just that:</p>
  
  <pre><code>  connection.Open()
    command.CommandType = CommandType.StoredProcedure
    command.CommandText = "RPT_C_S_H"          
    command.Parameters("@theOutput").Direction = ParameterDirection.Output  'returns 0 if bad, 1 if good
    Dim dataReader As SqlDataReader = command.ExecuteReader()
  </code></pre>
  
  <p>So now do i just do a</p>
  
  <pre><code>dim returnedValue as integer = 0
  
  Do While dataReader.Read()
       returnedValue = dataReader(0)
  Loop
  </code></pre>
  
  <p>in order to get the returned value?</p>
  
  <p>Any help would be great! Thanks!</p>
  
  <p>David</p>
  
  <p><strong>UPDATE</strong></p>
  
  <pre><code>connection.Open()
  command.CommandType = CommandType.StoredProcedure
  command.CommandText = "RPT_C_S_H"
  Dim sqlParReturn As System.Data.SqlClient.SqlParameter = command.Parameters.Add("@theOutput", SqlDbType.SmallInt)
  sqlParReturn.Direction = ParameterDirection.ReturnValue
  command.ExecuteNonQuery()
  Dim returnedValue As Integer = CInt(sqlParReturn.Value)
  </code></pre>
  
  <p><strong>UPDATE #2</strong></p>
  
  <pre><code>  Dim sqlParReturn1 As System.Data.SqlClient.SqlParameter = command.Parameters.Add("@Error_Code", SqlDbType.Int)
    Dim sqlParReturn2 As System.Data.SqlClient.SqlParameter = command.Parameters.Add("@Err_Msg", SqlDbType.VarChar)
    Dim sqlParReturn3 As System.Data.SqlClient.SqlParameter = command.Parameters.Add("@result", SqlDbType.Bit)
  
    sqlParReturn1.Direction = ParameterDirection.Output
    sqlParReturn2.Direction = ParameterDirection.Output
    sqlParReturn3.Direction = ParameterDirection.Output
  
    command.ExecuteNonQuery()
    Dim returnedValue1 As String = sqlParReturn1.Value
    Dim returnedValue2 As String = sqlParReturn2.Value
    Dim returnedValue3 As String = sqlParReturn3.Value
  </code></pre>
  
  <p>The SP looks like this:</p>
  
  <pre><code>  ALTER PROCEDURE [dbo].[CSS_SP_Job_Return] (
      @job INT,
      @UserID VARCHAR(50),
      @Printer_Name VARCHAR(30),
      @Error_Code int OUTPUT,
      @Err_Msg  varchar (1000) OUTPUT,
      @result BIT OUTPUT
    )
  </code></pre>
  
  <p>I keep getting the error: <strong>String[4] the size property has an invalid size of 0</strong></p>
  
  <p>What does that mean?</p>