B
Ben Smith
First off, I think there is a bug in the Data ApplicationBlocks when it comes to Output parameters. Even when I specify the direction the SQLHelper.ExecuteReader method still treats the parameter as an input parameter. But on to my questions...
I am having trouble returning a values back from a SQLCommand object using an output parameter. Where as the Application Blocks problem was creating the wrong command text, the SQLCommand is generating the right text but is not capturing the returned parameter value. Any ideas?
See my code below:
Dim pTotalChange As New SqlParameter("@intTotalChanges", SqlDbType.Int)
pTotalChange.Direction = ParameterDirection.Output
'SQLReader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "uspGetChangeCount", pTotalChange)
conn.Open()
SQLCommand.Connection = conn
SQLCommand.CommandText = "uspGetChangeCount"
SQLCommand.CommandType = CommandType.StoredProcedure
SQLCommand.Parameters.Add(pTotalChange)
SQLReader = SQLCommand.ExecuteReader(CommandBehavior.CloseConnection)
Here is the generated SQL as seen through SQL Profiler:
declare @P1 int
set @P1=0
exec uspGetChangeCount @intTotalChanges = @P1 output
select @P1
I am having trouble returning a values back from a SQLCommand object using an output parameter. Where as the Application Blocks problem was creating the wrong command text, the SQLCommand is generating the right text but is not capturing the returned parameter value. Any ideas?
See my code below:
Dim pTotalChange As New SqlParameter("@intTotalChanges", SqlDbType.Int)
pTotalChange.Direction = ParameterDirection.Output
'SQLReader = SqlHelper.ExecuteReader(conn, CommandType.StoredProcedure, "uspGetChangeCount", pTotalChange)
conn.Open()
SQLCommand.Connection = conn
SQLCommand.CommandText = "uspGetChangeCount"
SQLCommand.CommandType = CommandType.StoredProcedure
SQLCommand.Parameters.Add(pTotalChange)
SQLReader = SQLCommand.ExecuteReader(CommandBehavior.CloseConnection)
Here is the generated SQL as seen through SQL Profiler:
declare @P1 int
set @P1=0
exec uspGetChangeCount @intTotalChanges = @P1 output
select @P1