oracle数据库事务不能Rollback()的问题。(c#编码)
public Execute_SQL_Array(ArrayList CommandList ) 说明:CommandList 中存放一组SQL语句
{
//创建一个连接实例
if ( ConnectDatabase () < 0)
{
//连接数据库失败
return ;
}
OracleCommand _Command = new OracleCommand () ;
_Command.Connection =mConn.Conn ;
//创建事务
OracleTransaction _trans;
//启动一个事务
_trans = mConn.Conn.BeginTransaction() ;
_Command.Transaction = _trans ;
int i = 0;
try
{
for ( i = 0; i < CommandList.Count ; i++)
{
_Command.CommandType = CommandType.Text ;
_Command.CommandText = CommandList[i].ToString ();
_Command.ExecuteNonQuery() ;
}
//提交事务
_trans.Commit () ;
}
catch (Exception ex)
{
mResult = -40003 ;
mResultString = "执行SQL语句错误: "+ex.ToString ()+ "\r\n "+CommandList[i].ToString () ;
_trans.Rollback(); return ;
}
finally
{
mConn.Conn.Close () ;
}
}
CommandList 中存放一组SQL语句如下:
"insert into \ "TableList\ " (\ "ID\ ",\ "tableName\ ",\ "tableNameCN\ ",\ "createDepart\ ",\ "createDate\ ",\ "isInUse\ ") values (47, 'UDT_0002_NJXX ', '年检信息 ', '0002 ',SYSDATE,0) "
"insert into \ "ColumnList\ " (\ "ID\ ",\ "tableBelongTo\ ",\ "columnName\ ",\ "columnNameCN\ ",\ "dataType\ ",\ "showOrder\ ",\ "ColumnNameDescript\ ",\ "ShowMaster\ ") values (128, 'UDT_0002_NJXX ', 'QYZCH ', '企业注册号 ', 'varchar2(26) ',001, '企业注册号码 ',0) "
"insert into \ "ColumnList\ " (\ "ID\ ",\ "tableBelongTo\ ",\ "columnName\ ",\ "columnNameCN\ ",\ "dataType\ ",\ "showOrder\ ",\ "ColumnNameDescript\ ",\ "ShowMaster\ ") values (129, 'UDT_0002_NJXX ', 'QYMC ', '企业名称 ', 'varchar2(100) ',002, '企业登记的名称 ',0) "
"insert into \ "ColumnList\ " (\ "ID\ ",\ "tableBelongTo\ ",\ "columnName\ ",\ "columnNameCN\ ",\ "dataType\ ",\ "showOrder\ ",\ "ColumnNameDescript\ ",\ "ShowMaster\ ") values (130, 'UDT_0002_NJXX ', 'NJND ', '年检年度 ', 'varchar2(4) ',003, '工商年检年度 ',0) "
"insert into \ "ColumnList\ " (\ "ID\ ",\ "tableBelongTo\ ",\ "columnName\ ",\ "columnNameCN\ ",\ "dataType\ ",\ "showOrder\ ",\ "ColumnNameDescript\ ",\ "ShowMaster\ ") values (131, 'UDT_0002_NJXX ', 'NJJG ', '年检情况 ', 'varchar2(1000) ',004, '年检情况 ',0) "
"Create Table \ "UDT_0002_NJXX\ " (QYZCH varchar2(26) NOT NULL,QYMC varchar2(100) NOT NULL,NJND varchar2(4) NOT NULL,NJJG varchar2(1000) NOT NULL) "