output parameter in execute reader

i am trying to get the output for parameter status.  i am getting this error below.  Could you check my sub and make sure that is well written.  

Error-Procedure 'wmItemOptionVerifyCustomerSp' expects parameter '@status', which was not supplied.
Public Sub VerifyCustomer()
        Dim strConn2 As String = ConfigurationManager.ConnectionStrings("Test").ConnectionString
        Dim conn2 As New SqlConnection(strConn2)
 
        conn2.Open()
 
        Dim cmd2 As New Data.SqlClient.SqlCommand("wmItemOptionVerifyCustomerSp", conn2)
        cmd2.CommandType = CommandType.StoredProcedure
 
        cmd2.Parameters.Add("@cust_num", SqlDbType.NVarChar).Value = custnumber.Text
        cmd2.Parameters.Add("@name", SqlDbType.NVarChar).Value = fullname.Text
        cmd2.Parameters.Add("@zip", SqlDbType.NVarChar).Value = zip.Text
        
        Dim countPrm As New SqlParameter("@status", SqlDbType.NVarChar)
 
        countPrm.Direction = ParameterDirection.Output
 
        cmd.Parameters.Add(countPrm)
 
        Session("ok") = countPrm.Value
        Dim dr As Data.SqlClient.SqlDataReader = Nothing
 
        dr = cmd2.ExecuteReader()
        While dr.Read()
         
        End While
        conn2.Close()
        conn2.Dispose()
    End Sub

Open in new window

LVL 1
gianitooAsked:
Who is Participating?
 
spprivateConnect With a Mentor Commented:
This line is the problem


        cmd.Parameters.Add(countPrm)

This should be


        cmd2.Parameters.Add(countPrm)
0
 
gianitooAuthor Commented:
now i get this
Error-String[3]: the Size property has an invalid size of 0.
0
 
spprivateCommented:
That is not from this procedure.It is elsewhere in your code.
Where are you checking that in your code
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.