dbcommand.parameters not reflecting the correct value

Topics: Data Access Application Block
Feb 11, 2011 at 12:32 AM

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 11, 2011 at 12:45 AM


Can you post your relevant code here?

Feb 11, 2011 at 1: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 2:03 AM

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