本文整理汇总了C#中CUBRID.Data.CUBRIDClient.CUBRIDConnection.GetAutoCommit方法的典型用法代码示例。如果您正苦于以下问题:C# CUBRIDConnection.GetAutoCommit方法的具体用法?C# CUBRIDConnection.GetAutoCommit怎么用?C# CUBRIDConnection.GetAutoCommit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUBRID.Data.CUBRIDClient.CUBRIDConnection
的用法示例。
在下文中一共展示了CUBRIDConnection.GetAutoCommit方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AutoCommit_SetAfterOpen_Test
public void AutoCommit_SetAfterOpen_Test()
{
int tablesCount;
Log("Test SetAutoCommit, GetAutoCommit, AutoCommit");
LogTestStep("Set AutoCommit as false");
using (CUBRIDConnection conn = new CUBRIDConnection())
{
conn.ConnectionString = DBHelper.connString;
conn.Open();
conn.SetAutoCommit(false);
tablesCount = (int)DBHelper.GetSingleValue("select count(*) from db_class", conn);
//Create table
DBHelper.ExecuteSQL("create table xyz(id int)", conn);
//Verify the current AutoCimmit value
Assert.AreEqual(false, conn.GetAutoCommit());
}
using (CUBRIDConnection conn2 = new CUBRIDConnection())
{
conn2.ConnectionString = DBHelper.connString;
conn2.Open();
//Verify table was not created
Assert.AreEqual(tablesCount, (int)DBHelper.GetSingleValue("select count(*) from db_class", conn2));
LogStepPass();
LogTestStep("Set AutoCommit as true");
conn2.SetAutoCommit(true);
//Create table
DBHelper.ExecuteSQL("create table xyz(id int)", conn2);
//Verify the current AutoCimmit value
Assert.AreEqual(true, conn2.GetAutoCommit());
}
using (CUBRIDConnection conn3 = new CUBRIDConnection())
{
conn3.ConnectionString = DBHelper.connString;
conn3.Open();
//Verify table was created
Assert.AreEqual(tablesCount + 1, (int)DBHelper.GetSingleValue("select count(*) from db_class", conn3));
LogStepPass();
LogTestStep("Set AutoCommit as default");
//Leave the AutoCommit as default
DBHelper.ExecuteSQL("drop table if exists xyz", conn3);
Assert.AreEqual(true, conn3.GetAutoCommit());
}
using (CUBRIDConnection conn4 = new CUBRIDConnection())
{
conn4.ConnectionString = DBHelper.connString;
conn4.Open();
//Verify table was deleted
Assert.AreEqual(tablesCount, (int)DBHelper.GetSingleValue("select count(*) from db_class", conn4));
LogStepPass();
}
LogTestResult();
}
示例2: Test_GetAutoCommit
private static void Test_GetAutoCommit()
{
try
{
CUBRIDConnection conn = new CUBRIDConnection();
conn.GetAutoCommit();
}
catch (Exception e)
{
Debug.Assert(e.Message == "The connection is not open!");
}
try
{
CUBRIDConnection conn = new CUBRIDConnection();
conn.ConnectionString = connString;
conn.Open();
conn.GetAutoCommit();
conn.Close();
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}