{
cmd = CreateDbCommd(sqlConn, trans, sqlStr, cmdType, listParams);
result = cmd.ExecuteScalar();
trans.Commit();
}
catch (Exception e)
{
trans.Rollback();
throw new Exception("执行数据库操作失败, sql: " + sqlStr, e);
}
finally
{
trans.Dispose();
CloseConnection();
}
return result;
}
public int ExecuteNonQuery(string sqlStr, CommandType cmdType, List<DbParameter> listParams)
{
int result = -1;
OpenConnection();
DbTransaction trans = sqlConn.BeginTransaction();
try
{
cmd = CreateDbCommd(sqlConn, trans, sqlStr, cmdType, listParams);
result = cmd.ExecuteNonQuery();
trans.Commit();
}
catch (Exception e)
{
trans.Rollback();
throw new Exception("执行数据库操作失败, sql: " + sqlStr, e);
}
finally
{
trans.Dispose();
CloseConnection();
}
return result;
}
/// <summary>
/// 批量插入
/// </summary>
/// <param name="tableName"></param>
/// <param name="batchSize"></param>
/// <param name="copyTimeout"></param>
/// <param name="dt"></param>
/// <returns></returns>
public bool ExecuteBatchInsert(string tableName, int batchSize, int copyTimeout, DataTable dt)
{
bool flag = false;
try
4/13 首页 上一页 2 3 4 5 6 7 下一页 尾页 |