IDbDataParameter 是什麼數據類型?

dgitnet 2010-09-25 02:18:55
大家好!
IDbDataParameter 是什麼數據類型?
以下是sqlhelper.cs中的一段代碼,如何理解?

private static void AssignParameterValues(SqlParameter[] commandParameters, object[] parameterValues)
{
if ((commandParameters == null) || (parameterValues == null))
{
// Do nothing if we get no data
return;
}
// 确保对象数组个数与参数个数匹配,如果不匹配,抛出一个异常.
// We must have the same number of values as we pave parameters to put them in
if (commandParameters.Length != parameterValues.Length)
{
throw new ArgumentException("参数值个数与参数不匹配.");
//throw new ArgumentException("Parameter count does not match Parameter Value count.");
}

// 给参数赋值
// Iterate through the SqlParameters, assigning the values from the corresponding position in the
// value array
for (int i = 0, j = commandParameters.Length; i < j; i++)
{
// If the current array value derives from IDbDataParameter, then assign its Value property
if (parameterValues[i] is IDbDataParameter)
{
IDbDataParameter paramInstance = (IDbDataParameter)parameterValues[i];
if (paramInstance.Value == null)
{
commandParameters[i].Value = DBNull.Value;
}
else
{
commandParameters[i].Value = paramInstance.Value;
}
}
else if (parameterValues[i] == null)
{
commandParameters[i].Value = DBNull.Value;
}
else
{
commandParameters[i].Value = parameterValues[i];
}
}
}
...全文
129 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
dgitnet 2010-09-28
  • 打赏
  • 举报
回复
還是看不懂
wuyq11 2010-09-25
  • 打赏
  • 举报
回复
IDbDataParameter 接口
用来向 Command 对象表示一个参数,以及向该对象的 DataSet 列映射表示参数(可选)
http://msdn.microsoft.com/zh-cn/library/system.data.idbcommand(VS.80).aspx

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧