首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

关于Parameters的有关问题,求解答,多谢了

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

关于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

热点排行