<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
Using Stored Procedures With Output Parameters
---------------------------------------------------
Imports System
Imports System.Data
Imports System.Data.SqlClient
Module Module1
Sub Main()
Dim cn As SqlConnection
Dim sql As String
Dim cmd As SqlCommand
cn = New SqlConnection("Data Source=PEREGRINE;" & _
"Initial Catalog=Northwind;Integrated Security=SSPI")
cn.Open()
sql = "CREATE PROCEDURE sp_CustomersByStateWithCount @region nvarchar(15), @matches int OUTPUT AS " & _
"SELECT CustomerID, CompanyName FROM Customers WHERE region = @region ORDER BY CompanyName " & _
"SET @matches = @@rowcount"
cmd = New SqlCommand(sql, cn)
cmd.ExecuteNonQuery()
Console.WriteLine("Procedure created!")
End Sub
End Module