本文整理汇总了C#中IDbHelper.ExecuteNonQuery方法的典型用法代码示例。如果您正苦于以下问题:C# IDbHelper.ExecuteNonQuery方法的具体用法?C# IDbHelper.ExecuteNonQuery怎么用?C# IDbHelper.ExecuteNonQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDbHelper
的用法示例。
在下文中一共展示了IDbHelper.ExecuteNonQuery方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Truncate
/// <summary>
/// 截断表格数据
/// </summary>
/// <param name="dbHelper">数据库连接</param>
/// <param name="tableName">目标表格</param>
/// <returns>是否成功</returns>
public static int Truncate(IDbHelper dbHelper, string tableName)
{
string sqlQuery = " TRUNCATE TABLE " + tableName;
// DB2 V9.7 以后才支持这个语句
if (dbHelper.CurrentDbType == DbTypes.DB2)
{
sqlQuery = " ALTER TABLE " + tableName + " ACTIVATE NOT LOGGED INITIALLY WITH EMPTY TABLE ";
}
return dbHelper.ExecuteNonQuery(sqlQuery);
}
示例2: Delete
/// <summary>
/// 删除表格数据
/// </summary>
/// <param name="dbHelper">数据库连接</param>
/// <param name="tableName">目标表名</param>
/// <param name="parameters">删除条件</param>
/// <returns>影响行数</returns>
public static int Delete(IDbHelper dbHelper, string tableName, List<KeyValuePair<string, object>> parameters = null)
{
string sqlQuery = " DELETE " + " FROM " + tableName;
string whereString = GetWhereString(dbHelper, parameters, BaseBusinessLogic.SQLLogicConditional);
if (whereString.Length > 0)
{
sqlQuery += " WHERE " + whereString;
}
return dbHelper.ExecuteNonQuery(sqlQuery, dbHelper.MakeParameters(parameters));
}