Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#3105 [OLEDB] OdbcConnection.BeginTransaction failed with IsolationLevel Snapshot and Chaos

open
nobody
None
5
2013-04-28
2013-04-28
Jira Trac
No

* Brief:
** OdbcConnection.BeginTransaction failed with IsolationLevel Snapshot. it will throw an exception
** Exception
{noformat}
CubridOleDbInterface.OleDbTransactionTest.Level_Chaos:
System.Data.OleDb.OleDbException : “CUBRIDProvider”失败,没有可用的错误消息,结果代码: XACT_E_ISOLATIONLEVEL(0x8004D008)。
{noformat}
** This issue is same or similar with an ODBC issue: APIS-537

* Test Code
{noformat}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;

namespace CubridOleDbInterface
{
class bts_issue
{
static void Main(string[] args)
{
bts_issue issue = new bts_issue();
issue.testcase1();
}

public void testcase1()
{
string connStr =
@Provider=CUBRIDProvider.1;Data Source=testdb;Persist Security Info=False;
Location=10.34.64.58;User ID=dba;Cache Authentication=False;Encrypt Password=False;
Mask Password=False;Persist Encrypted=False;Port=33022;Fetch Size=100;

string sql1 = drop table if exists t1;
string sql2 = create table t1(id int);
string sql3 = insert into t1 values(1);
string sql4 = insert into t1 values(2);
string sql5 = select count(*) from t1;

OleDbConnection conn = new OleDbConnection(connStr);
conn.Open();
OleDbCommand cmd = conn.CreateCommand();
OleDbTransaction tr = null;
cmd.CommandText = sql1;
cmd.ExecuteNonQuery();
cmd.CommandText = sql2;
cmd.ExecuteNonQuery();

//tr = conn.BeginTransaction(IsolationLevel.Snapshot);
tr = conn.BeginTransaction(IsolationLevel.Chaos);

cmd.Transaction = tr;
cmd.CommandText = sql3;
cmd.ExecuteNonQuery();
cmd.CommandText = sql4;
cmd.ExecuteNonQuery();

tr.Rollback();

cmd.CommandText = sql5;
OleDbDataReader reader = cmd.ExecuteReader();
reader.Read();

Console.WriteLine(reader.GetInt32(0));
reader.Close();
cmd.Dispose();
conn.Close();
}
}
}
{noformat}

Discussion