本文整理汇总了C#中Microsoft.Practices.EnterpriseLibrary.Data.Database.SetParameterValue方法的典型用法代码示例。如果您正苦于以下问题:C# Database.SetParameterValue方法的具体用法?C# Database.SetParameterValue怎么用?C# Database.SetParameterValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Practices.EnterpriseLibrary.Data.Database
的用法示例。
在下文中一共展示了Database.SetParameterValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrepCommand
private static DbCommand PrepCommand(Database db, string procName, params object[] parameterVals)
{
DbCommand dbCommand = db.GetStoredProcCommand(procName);
dbCommand.CommandTimeout = 180;
db.DiscoverParameters(dbCommand);
int numVals = parameterVals.Length;
/// Start at 1; skip 0 which is RETURN_VALUE.
for (int i = 1; i < dbCommand.Parameters.Count; i++)
{
/// parameterVals should have same # elements, but index is offset by 1 compared to dbCommand.Parameters.
int valIndex = i - 1;
object value = valIndex < numVals ? parameterVals[valIndex] : null;
db.SetParameterValue(dbCommand, dbCommand.Parameters[i].ParameterName, value);
}
return dbCommand;
}
示例2: ResetOrderPrintStatus
public override int ResetOrderPrintStatus(IList<OrderInfo> orders)
{
int num = 0;
database = DatabaseFactory.CreateDatabase();
StringBuilder builder = new StringBuilder();
builder.Append("UPDATE Hishop_Orders SET IsPrinted=0 WHERE [email protected]");
DbCommand sqlStringCommand = database.GetSqlStringCommand(builder.ToString());
database.AddInParameter(sqlStringCommand, "OrderId", DbType.String);
try
{
foreach (OrderInfo info in orders)
{
database.SetParameterValue(sqlStringCommand, "OrderId", info.OrderId);
num += database.ExecuteNonQuery(sqlStringCommand);
}
}
catch
{
}
return num;
}