读书人

关于Parameters的有关问题求解答多

发布时间: 2011-12-30 23:30:45 作者: rapoo

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

读书人网 >C#

热点推荐