日期:2014-05-18  浏览次数:20320 次

请帮我看一下,为什么不能获得存储过程里的输出参数值
在SqlServer2005管理器里存储过程,执行结果:   @Total     2         ReturnValue   0

可是在asp.net的SQLDataSource1的Selected的事件里的代码:

protected   void   SqlDataSource1_Selected(object   sender,   SqlDataSourceStatusEventArgs   e)
{
      int   aa   =   Convert.ToInt32(e.Command.Parameters[ "@Total "].Value);
}

设置断点,调试     aa   =   0   ,   e.Command.Parameters[ "@Total "].Value   =   null

请问这是为什么呢?请大哥们指教一下,谢谢!!!!


------解决方案--------------------
int aa = Convert.ToInt32(e.Command.Parameters[ "@Total "].direction);??
------解决方案--------------------
先设置参数为输出参数
SqlCmd.Parameters[ "@Total "].Direction = ParameterDirection.Output;
然后就可以取值了