using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data;
using Oracle.DataAccess.Client;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
using System.Diagnostics;
using System.Data.Common;
using System.Collections;
namespace DB_Server
{
#region //操作Oracle数据库
public class OracleDBService
{
public OracleDBService(string ConnectionString)
{
OracleConStr = ConnectionString;
}
#region//连接数据库所需变量及方法
private string OracleConStr = "";
private OracleConnection conn;//创建sql连接
private OracleCommand com;//创建sql命令对象
private OracleDataReader dr;//创建sql数据阅读器
private OracleDataAdapter sdr;//创建sql适配器
private DataSet ds;//创建数据集
/// <summary>
/// 创建数据库连接并打开
/// </summary>
public void open()
{
//创建连接
conn = new OracleConnection(OracleConStr);
if (conn.State == ConnectionState.Closed)
{
conn.Open();
}
else if (conn.State == ConnectionState.Broken)
{
conn.Close();
conn.Open();
}
}
#region//事务操作数据库
/// <summary>
/// 提交一组(多条)SQL语句操作数据库
/// </summary>
/// <param>SQL列表</param>
/// <returns>执行结果</returns>
public int UpdateBatchCommand(ArrayList commandStringList)
{
open();
OracleTransaction m_OraTrans = conn.BeginTransaction();//创建事务对象
com = new OracleCommand();
com.Connection = conn;
string tmpStr = "";
int influenceRowCount = 0;
try
{
foreach (string commandString in commandStringList)
{
tmpStr = commandString;
com.CommandText = tmpStr;
influenceRowCount += com.ExecuteNonQuery();
}
m_OraTrans.Commit();
return influenceRowCount;
}
catch (OracleException ex)
{
m_OraTrans.Rollback();
throw ex;
}
}
#endregion
Oracle多用户对一个表进行并发插入数据行操作(2)
内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:https://www.heiqu.com/9374e5f20aa4c62b246f88b4a187b9c3.html