I have a stored procedure that returns two sets of records that I call using GetReader. I repeat first, call IDataReader.NextResult (), and then iterate over the second.
I assign values to the output parameters in sp, but when I check the values after finishing my reading, my output parameters are zero. Looks like a mistake. I don’t want to use select because I don’t like fudge. Some fragments ...
...
sp.Command.AddParameter("@SelectedTabID", selectedTabID, DbType.Int32);
sp.Command.AddParameter("@CurrentTabID", 0, DbType.Int32, ParameterDirection.Output);
sp.Command.AddParameter("@TypeID", 0, DbType.Int32, ParameterDirection.Output);
(pay attention to the implementation of this method or using AddOutputParameter () gives the same results)
...
using(IDataReader reader = sp.GetReader())
{
while (reader.Read()) {...}
if (reader.NextResult()) {while (reader.Read()) {...}}
}
...
int one = (int)sp.OutputValues[0];
int two = (int)sp.OutputValues[1];
Looking forward to some gems of wisdom :)
Al
source
share