日期:2014-05-19  浏览次数:20695 次

关于Parameters的问题,求解答,谢谢了
这个是一个向sqlcommand加sqlParameter[]的方法:如下

private   void   AttachParameters(SqlCommand   command,   SqlParameter[]   commandParameters)
        {
                        foreach   (SqlParameter   p   in   commandParameters)
                        {
                                if   ((p.Direction   ==   ParameterDirection.InputOutput)   &&   (p.Value   ==   null))
                                {
                                        p.Value   =   DBNull.Value;
                                }
                                command.Parameters.Add(p);
                        }
                  }

但是,谁能解释一下,下面的代码是什么意思?
  if   ((p.Direction   ==   ParameterDirection.InputOutput)   &&   (p.Value   ==   null))
                                {
                                        p.Value   =   DBNull.Value;
                                }

谢谢了,看不明白

------解决方案--------------------
if ((p.Direction == ParameterDirection.InputOutput) && (p.Value == null))
{
p.Value = DBNull.Value;
}
这句的意思是,是输入输出参数,并且参数值不能为空,如果这两个条件都满足它的值就设值为DBNull.value