title: Calling SQL Server stored procedure in VB
body: <p>I wrote a SQL Server stored procedure based on my previous question that I asked which was answered that is why I am creating a new question. </p>
  
  <p>STORED PROCEDURE</p>
  
  <pre><code>ALTER Procedure [dbo].[usp_validatecard](
  @CLUBCARD1 nvarchar(50),
  @STATUS nvarchar(50))
  As
  
  BEGIN
  IF EXISTS(Select CLUBCARD1, STATUS
  from dbo.clubmembers 
  where CLUBCARD1 = @CLUBCARD1 and STATUS = 'ACTIVE')
  Print 'Card is GOOD'
  ELSE
  IF EXISTS(SELECT CLUBCARD1, STATUS
  FROM dbo.clubmembers
  where CLUBCARD1 = @CLUBCARD1 and STATUS = 'INACTIVE')
  PRINT 'Card is good but not active'
  ELSE
  PRINT 'CARD NOT IN SYSTEM'
  END
  </code></pre>
  
  <p>The trouble I am having is not too sure how to call that in VB. The code I have so far is this</p>
  
  <pre><code>Imports System.Data.SqlClient
  Imports System.Web.Configuration
  Imports System.Data
  
  Partial Class _Default
      Inherits System.Web.UI.Page
  
      Protected Sub cmdclick_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdclick.Click
          Dim strConnString As String = WebConfigurationManager.ConnectionStrings("orca").ConnectionString
          Dim con As New SqlConnection(strConnString)
          Dim cmd As New SqlCommand("usp_validatecard", con)
          cmd.CommandType = Data.CommandType.StoredProcedure
  
          cmd.Parameters.Add("@CLUBCARD1", Data.SqlDbType.NVarChar).Value = txtvalidate.Text
  
          Try
              con.Open()
              Dim Result As Integer = cmd.ExecuteNonQuery()
          Catch ex As SqlException
              lblmessage.Text = "Error"
          Finally
              con.Close()
          End Try
      End Sub
  End Class
  </code></pre>
  
  <p>What I am trying to do is if the clubcard parameter is found and status is active I would like the label to read 'card is good' also if the clubcard parameter is found however is inactive then the label should read 'card is good but not active' last if all those fail just have the label read 'card not in system'</p>
  
  <p>As of right now this code does not work I thought I could just call the stored procedure and exec it and it would print the statements depending on what passes however it is erroring out. </p>
  
  <p>When I debug it the error I get is under the cmd.parameters.add is </p>
  
  <blockquote>
    <p>Item In order to evaluate an indexed
    property, the property must be
    qualified and the arguments must be
    explicitly supplied by the user.</p>
  </blockquote>