Here's a simple code snippet of a larger function as an example.
Using conn as New SqlConnection("conn string")
Using find as new SqlCommand("ExampleProc",conn)
Dim rParam as new SqlParameter("@RESULT",SqlDbType.Int)
rParam.Direction = ParameterDirection.Output
find.Pareameters.Add(rParam)
Using f as SqlDataReader = find.ExecuteReader
'Do stuff with datareader
End Using
updateResult.Success = Convert.ToBoolean(find.Parameters("@RESULT").Value)
End Using
End Using
I know the Output parameter is returned after the SqlDataReader is closed. From what I think I know, the Using statement will call .Dispose
on the SqlDataReader, so will that basically wipe out the Output parameter? If so, what is the best method to call a SqlDataReader that also contains Output parameters that closes and disposes everything correctly? I couldn't find any specific info or examples online in my searching. Thanks!
Let me add that based on what I've read you only have access to the Output parameter using a SqlDataReader after you call .Close on the SqlDataReader.