Public Sub StoredProcExample() ' Create a new Connection Dim oConnection As SqlConnection oConnection = New SqlConnection("data source=(local);initial catalog=BM; user id=kevin; password=mypw") oConnection.Open() Dim oDataSet As New DataSet Dim oSqlAdapter = New SqlDataAdapter("sp_GetCustomerById", oConnection) oSqlAdapter.SelectCommand.CommandType = CommandType.StoredProcedure oSqlAdapter.SelectCommand.Parameters.Add("@CustomerId", "SMITH") oSqlAdapter.Fill(oDataSet, "Customers") Dim oDataRow As DataRow For Each oDataRow In oDataSet.Tables("Customers").Rows Console.WriteLine(oDataRow("CustomerId").ToString()) Next oConnection.Close() End Sub>Kevin,
>CREATE PROCEDURE GetCustomerByPK (@nCustomerPK int) > AS > > SELECT * FROM Customer WHERE CustomerPK = @nCustomerPK >GO >>