dbcommand.parameters not reflecting the correct value

Topics: Data Access Application Block
Feb 10, 2011 at 11:32 PM

Hi, I have a stored procedure with an output parameter and executed it using ExecuteNonQuery.  Of course, I added the necessary parameters prior to executing but after I call ExecuteNonQuery, I inspected the dbCommand.Parameters property and saw that my output parameter didn't get updated based on the stored proc's execution.  Can anyone tell me what am I doing wrong?  How do I get the value of my output parameter?


Feb 10, 2011 at 11:45 PM


Can you post your relevant code here?

Feb 11, 2011 at 12:44 AM

Thank you for your reply.  Here's the relevant code:

Database db = DatabaseFactory.CreateDatabase();
DbCommand command = db.GetStoredProcCommand(spName);
db.AddOutParameter(command, "RecordCount", DbType.Int, 4);

in recordCount = int.Parse(command.Parameters[0].Value.ToString());


Feb 11, 2011 at 1:03 AM

Your code looks fine. Can you also post your stored proc?