本文整理汇总了C#中OracleTransaction类的典型用法代码示例。如果您正苦于以下问题:C# OracleTransaction类的具体用法?C# OracleTransaction怎么用?C# OracleTransaction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OracleTransaction类属于命名空间,在下文中一共展示了OracleTransaction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteNonQuery
/// <summary>
/// 执行数据库事务查询操作,返回受影响的行数
/// </summary>
/// <param name="transaction">数据库事务对象</param>
/// <param name="cmdType">Command类型</param>
/// <param name="cmdText">Oracle存储过程名称或PL/SQL命令</param>
/// <param name="commandParameters">命令参数集合</param>
/// <returns>当前事务查询操作影响的数据行数</returns>
public static int ExecuteNonQuery(OracleTransaction transaction, CommandType cmdType, string cmdText, params OracleParameter[] commandParameters)
{
OracleCommand command = new OracleCommand();
OracleConnection connection = transaction.Connection;
int result = 0;
try
{
PrepareCommand(command, connection, transaction, cmdType, cmdText, commandParameters);
result = command.ExecuteNonQuery();
command.Parameters.Clear();
}
catch
{
throw;
}
finally
{
transaction.Dispose();
command.Dispose();
connection.Close();
connection.Dispose();
}
return result;
}
示例2: ExecuteNonQuery
/// <summary>
/// Execute an OracleCommand (that returns no resultset) against an existing database transaction
/// using the provided parameters.
/// </summary>
/// <remarks>
/// e.g.:
/// int result = ExecuteNonQuery(trans, CommandType.StoredProcedure, "PublishOrders", new OracleParameter(":prodid", 24));
/// </remarks>
/// <param name="trans">an existing database transaction</param>
/// <param name="commandType">the CommandType (stored procedure, text, etc.)</param>
/// <param name="commandText">the stored procedure name or PL/SQL command</param>
/// <param name="commandParameters">an array of OracleParamters used to execute the command</param>
/// <returns>an int representing the number of rows affected by the command</returns>
public static int ExecuteNonQuery(OracleTransaction trans, CommandType cmdType, string cmdText, params OracleParameter[] commandParameters)
{
OracleCommand cmd = new OracleCommand();
PrepareCommand(cmd, trans.Connection, trans, cmdType, cmdText, commandParameters);
int val = cmd.ExecuteNonQuery();
cmd.Parameters.Clear();
return val;
}
示例3: OracleCustomCommandBuilder
public OracleCustomCommandBuilder( DataTable dataTable, OracleConnection connection, ArrayList columnOracleTypes, OracleTransaction transaction)
{
if (dataTable.Columns.Count != columnOracleTypes.Count)
{
throw new ArgumentException("Number of OracleTypes does not match number of columns.");
}
this.dataTable = dataTable;
this.connection = connection;
this.columnOracleTypes = columnOracleTypes;
this.transaction = transaction;
}
示例4: ExecuteReaderSingleRow
/// <summary>
/// Create and execute a command to return a single-row DataReader after binding to multiple parameters.
/// </summary>
/// <param name="conn">Connection to execute against. If not open, it will be here.</param>
/// <param name="trans">ADO transaction. If null, will not be attached to the command</param>
/// <param name="cmdType">Type of ADO command; such as Text or Procedure</param>
/// <param name="cmdText">The actual SQL or the name of the Stored Procedure depending on command type</param>
/// <param name="cmdParms">An array of OracleParameter objects to bind to the query.</param>
public static OracleDataReader ExecuteReaderSingleRow(OracleConnection conn, OracleTransaction trans, CommandType cmdType, string cmdText, OracleParameter[] cmdParms)
{
if (conn.State != ConnectionState.Open)
conn.Open();
OracleCommand cmd = new OracleCommand();
cmd.Connection = conn;
cmd.CommandText = cmdText;
PrepareCommand(cmd, cmdParms);
OracleDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow);
return rdr;
}
示例5: ExecuteReaderSingleParm
/// <summary>
/// Create and execute a command to return DataReader after binding to a single parameter.
/// </summary>
/// <param name="conn">Connection to execute against. If not open, it will be here.</param>
/// <param name="trans">ADO transaction. If null, will not be attached to the command</param>
/// <param name="cmdType">Type of ADO command; such as Text or Procedure</param>
/// <param name="cmdText">The actual SQL or the name of the Stored Procedure depending on command type</param>
/// <param name="singleParm">The single OracleParameter object to bind to the query.</param>
public static OracleDataReader ExecuteReaderSingleParm(OracleConnection conn, OracleTransaction trans, CommandType cmdType, string cmdText, OracleParameter singleParm)
{
OracleCommand cmd = new OracleCommand();
if (conn.State != ConnectionState.Open)
conn.Open();
cmd.Connection = conn;
cmd.CommandText = cmdText;
cmd.Parameters.Add(singleParm);
OracleDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleResult);
return rdr;
}
示例6: GrabarMatriculaUpdate
public static void GrabarMatriculaUpdate(ref MatriculaDto mat, ref OracleConnection con, ref OracleTransaction tran)
{
var cmdPro = new OracleCommand("PRC_MATRICULA_UPDATE");
cmdPro.CommandType = CommandType.StoredProcedure;
cmdPro.Connection = con;
cmdPro.Parameters.Add(CreateParameter("iMTRID", mat.MtrId));//NUMBER
cmdPro.Parameters.Add(CreateParameter("iMTRDESCRIPCION", mat.MtrDescripcion, 45));//NUMBER
cmdPro.Transaction = tran;
cmdPro.ExecuteNonQuery();//EJECUTO CONSULTA
}
示例7: OracleDatabaseQuery
public OracleDatabaseQuery(
OracleConnection connection,
OracleTransaction transaction)
{
Contract.Requires(connection != null);
this.Connection = connection;
this.ConnectionString = connection.ConnectionString;
this.Transaction = transaction;
Queue =
new Lazy<OracleAQQueue>(() =>
{
var q = new OracleAQQueue("\"-NGS-\".NOTIFY_QUEUE", Connection, OracleAQMessageType.Udt, "-NGS-.NOTIFY_INFO_TYPE");
q.EnqueueOptions.Visibility = OracleAQVisibilityMode.OnCommit;
q.EnqueueOptions.DeliveryMode = OracleAQMessageDeliveryMode.Persistent;
return q;
});
}
示例8: GrabarMatriculaInsert
public static void GrabarMatriculaInsert(ref MatriculaDto mat, ref OracleConnection con, ref OracleTransaction tran)
{
#region INSERT Matricula del profesional -------------------------------------------------------------------
var cmdMat = new OracleCommand("PRC_MATRICULA_INSERT");
cmdMat.CommandType = CommandType.StoredProcedure;
cmdMat.Connection = con;
cmdMat.Parameters.Add(CreateParameter("iMTRDESCRIPCION", mat.MtrDescripcion, 45));//VARCHAR
cmdMat.Parameters.Add(CreateParameter("iMTR_MTTID", mat.MtrTipo.MttId));//NUMBER
cmdMat.Parameters.Add(CrearParametroSalida("oMTRID", OracleDbType.Int32));//NUMBER
cmdMat.Transaction = tran;
cmdMat.ExecuteNonQuery();
var varMtrId = cmdMat.Parameters["oMTRID"].Value;
mat.MtrId = Convert.ToInt16(varMtrId.ToString());
#endregion
}
示例9: PrepareCommand
/// <summary>
/// 为command添加执行内容
/// </summary>
/// <param name="cmd">OracleCommand类型</param>
/// <param name="conn">OracleConnection类型</param>
/// <param name="trans">OracleTransaction要处理的事物</param>
/// <param name="cmdType">执行类型(过程/语句)</param>
/// <param name="cmdText">执行的过程名称/查询语句</param>
/// <param name="cmdParms">ommand执行的OracleParameter[]数组</param>
private static void PrepareCommand(OracleCommand cmd, OracleConnection conn, OracleTransaction trans, CommandType cmdType, string cmdText, OracleParameter[] cmdParms)
{
if (conn.State != ConnectionState.Open)
Open(conn);
cmd.Connection = conn;
cmd.CommandText = cmdText;
if (trans != null)
cmd.Transaction = trans;
cmd.CommandType = cmdType;
if (cmdParms != null)
{
if (cmdParms.Length > 0)
{
foreach (OracleParameter parm in cmdParms)
cmd.Parameters.Add(parm);
}
}
}
示例10: GetConnection
public static OracleConnection GetConnection()
{
if (conn != null) {
if (conn.State == System.Data.ConnectionState.Open) {
return conn;
}
}
string DBName = "RA00C000";
string DBUser = "voshod";
string DBPass = "voshod";
string[] args = Environment.GetCommandLineArgs();
if (args.Length > 3) {
DBName = args[1];
DBUser = args[2];
DBPass = args[3];
}
oradb = "Data Source=" + DBName + ";User Id=" + DBUser + ";Password=" + DBPass + ";";
try {
conn = new OracleConnection(oradb);
conn.Open();
transaction = conn.BeginTransaction();
return conn;
} catch (Exception) {
return null;
}
}
示例11: Commit
public static void Commit()
{
if (conn != null) {
transaction.Commit();
transaction = conn.BeginTransaction();
}
}
示例12: CT2Repository
public CT2Repository()
{
this.con = ConnectionFactory.GetConnection();
if (this.con.State != ConnectionState.Open)
this.con.Open();
if(usaTransacao)
this._transaction = this.con.BeginTransaction();
}
示例13: SqlRunner
/// <summary>
/// Connects to the database.
/// </summary>
/// <param name="connDetails"></param>
public SqlRunner(ConnectionDetails connDetails)
{
this.connDetails = connDetails;
string connStr = GetConnectionString();
log.Info("connecting to [" + connDetails.Name + "] with connection string " + connStr);
conn = new OracleConnection(connStr);
conn.Open();
currentTransaction = conn.BeginTransaction();
}
示例14: BeginTransaction
public DataContextTransaction BeginTransaction()
{
if (Connection.State == ConnectionState.Closed)
Connection.Open();
if (Transaction == null)
Transaction = Connection.BeginTransaction();
return this;
}
示例15: Dispose
public void Dispose()
{
if (Transaction != null)
{
Transaction.Dispose();
Transaction = null;
}
if (Connection.State != ConnectionState.Closed)
Connection.Close();
}