Monday, May 15, 2006 9:25 PM
by
rjdudley
Using Output Parameters With Enterprise Library 2.0
I couldn't find a quick example when I was looking for one,
so here's mine.
First, create your stored procedure with an output
parameter:
CREATE PROCEDURE [dbo].[MySproc]
(@MyParameter
varchar(50) OUTPUT)
Then, add an output parameter to your database
command:
Dim _db As Database =
DatabaseFactory.CreateDatabase
Dim _cmd As DbCommand =
_db.GetStoredProcCommand("MySproc")
_db.AddOutParameter(_cmd,
"@MyParameter", DbType.Int32, 4)
Then, execute your stored procedure, and assign the
parameter value to a variable (remember to DIM the variable)
_db.ExecuteNonQuery(_cmd)
_result =
_db.GetParameterValue(_cmd, "@MyParameter")