当前位置: 首页>>代码示例>>C#>>正文


C# CUBRIDConnection.GetAutoCommit方法代码示例

本文整理汇总了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();
        }
开发者ID:CUBRID,项目名称:cubrid-adonet,代码行数:72,代码来源:CUBRIDConnectionTest.cs

示例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());
        }
    }
开发者ID:CUBRID,项目名称:cubrid-adonet,代码行数:25,代码来源:TestCUBRIDConnection.cs


注:本文中的CUBRID.Data.CUBRIDClient.CUBRIDConnection.GetAutoCommit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。