Knight Data Access Layer
Executing With Output Parameters VB.NET
Basic Tasks VB.NET > Database Commands > Executing With Output Parameters VB.NET

Here is an example of how to execute a stored procedure with output parameters:

 

'Get the current instance of the helper

Dim db As IDataHelper = DataHelper.SessionFactory()

Dim storedProcedure As String = "Insert_Customer"

 

'Parameters

Dim parameters As New List(Of IDbDataParameter)()

Dim primaryKeyOutput As IDbDataParameter = New System.Data.SqlClient.SqlParameter("@CustomerId",DbType.Int64)

primaryKeyOutput.Direction = ParameterDirection.Output

parameters.Add(primaryKeyOutput)

 

Dim affectedRecords As Integer = db.ExecuteNonQuerySproc(storedProcedure, parameters)

Console.WriteLine(parameters(0).Value)