Sub Submit(Source As Object, E As EventArgs)
Dim strConnection As String = ConfigurationSettings.AppSettings("NWind")
Dim objConnection As New SqlConnection(strConnection)
Dim objCommand As New SqlCommand("sp_CustomersByStateWithCount",objConnection)
objCommand.CommandType = CommandType.StoredProcedure
Dim objParameter As New SqlParameter("@region", SqlDbType.NVarChar, 15)
objCommand.Parameters.Add(objParameter)
objParameter.Direction = ParameterDirection.Input
objParameter.Value = txtRegion.text
Dim objOutputParameter As New SqlParameter("@matches", SqlDbType.Int)
objCommand.Parameters.Add(objOutputParameter)
objOutputParameter.Direction = ParameterDirection.Output
objConnection.Open()
Dim objDataReader As SqlDataReader
objDataReader = objCommand.ExecuteReader()
dgOutput.DataSource = objDataReader
dgOutput.DataBind()
objCommand.Connection.Close()
objCommand.Connection.Open()
objCommand.ExecuteNonQuery()
lblRecords.Text = "Matches: " & CInt(objCommand.Parameters(1).Value)
objConnection.close()