GetOutParameter DAAB

Topics: Data Access Application Block
Jun 11, 2007 at 3:54 PM
I´m trying to get a return value from an output parameter but it is always returning null.
If a execute the proc directly in Query analyser it works...
Does anyone can see the problem? Here's what I´m doing:

Database db = DatabaseFactory.CreateDatabase("DataBase");
DbCommand cmd = db.GetStoredProcCommand("my_proc");
db.AddInParameter(cmd, "idCliente", DbType.String,
HttpContext.Current.Session"idCliente");
db.AddOutParameter(cmd, "totalRecords", DbType.Int32, 4);
using (IDataReader dr = db.ExecuteReader(cmd))
{
totalRecords = (int)db.GetParameterValue(cmd, "totalRecords");
}
Jun 11, 2007 at 8:58 PM
This looks like a major bug to me, i have tested this, and its clearly not working. It works just fine with ExecuteNonQuery.

But i dont think the enterprice-library is making this bug. But i can be mistaken.

Regards
Benny

Jun 12, 2007 at 10:54 AM
Edited Jun 12, 2007 at 10:54 AM
I have a faint memory of that OutParameter only returns a value after all rows have been parsed in a reader.
Jun 12, 2007 at 1:57 PM
Right you are Joakim. When using a DataReader, you must close it or read to the end of the data before the output parameters are visible.

Regards,

Dave

_____________________________

David Hayden
Microsoft MVP C#
Jun 21, 2007 at 1:50 PM
thank you.


DavidHayden wrote:
Right you are Joakim. When using a DataReader, you must close it or read to the end of the data before the output parameters are visible.

Regards,

Dave

_____________________________

David Hayden
Microsoft MVP C#