这个是一个向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;
}谢谢了,看不明白
{
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;
}谢谢了,看不明白
解决方案 »
- 这个怎么做,请高手 !!!!!!PictureBox_MouseEnter()的时候中间层自动出现 鼠标划出 中间层的时候,中间层自动隐藏
- 怎么使Mediaplayer全屏播放
- 换系统导致时间格式差异
- ajax无刷新分页问题
- 谁能提供一下有关AspNetPager控件查询分页的例子
- 求助:怎么使WEB页面总是置顶显示?
- 绑定数据时,如何保持DataGrid绑定前的显示位置?(WinForm)
- 用System.Xml.XmlTextWriter创建XML的问题
- 为什么这样慢啊?
- 请教大虾一个小问题!
- c#如何打开已存入数据库的WORD文档,进行文档编辑或删除!在线
- c#連接informix數據庫的問題
{
p.Value = DBNull.Value;
}
这句的意思是,是输入输出参数,并且参数值不能为空,如果这两个条件都满足它的值就设值为DBNull.value
那么cmd.Parameters["@val"].Value=null 代表使用这个默认的 "AABB"
而cmd.Parameters["@val"].Value=DBNull.Value 代表使用NULL来传给 @val