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


C# CUBRIDConnection.BatchExecuteNoQuery方法代码示例

本文整理汇总了C#中CUBRID.Data.CUBRIDClient.CUBRIDConnection.BatchExecuteNoQuery方法的典型用法代码示例。如果您正苦于以下问题:C# CUBRIDConnection.BatchExecuteNoQuery方法的具体用法?C# CUBRIDConnection.BatchExecuteNoQuery怎么用?C# CUBRIDConnection.BatchExecuteNoQuery使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CUBRID.Data.CUBRIDClient.CUBRIDConnection的用法示例。


在下文中一共展示了CUBRIDConnection.BatchExecuteNoQuery方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BatchExecuteNoQuery_Test

        public void BatchExecuteNoQuery_Test()
        {
            using (CUBRIDConnection conn = new CUBRIDConnection())
            {
                LogTestStep("Test BatchExecute with serveral non-query sql statements");
                conn.ConnectionString = DBHelper.connString;
                conn.Open();

                DBHelper.ExecuteSQL("drop table if exists t", conn);

                string[] sql_arr = new string[4];
                sql_arr[0] = "create table t(id integer)";
                sql_arr[1] = "insert into t values(11)";
                sql_arr[2] = "insert into t values(22)";
                sql_arr[3] = "insert into t values(33)";
                int result = conn.BatchExecuteNoQuery(sql_arr);
                Assert.AreEqual(4, result);

                string sql = "select * from t";
                using (CUBRIDCommand cmd = new CUBRIDCommand(sql, conn))
                {
                    using (DbDataReader reader = cmd.ExecuteReader())
                    {
                        for (int i = 1; i < 4; i++)
                        {
                            reader.Read();
                            Assert.AreEqual(i * 11, reader.GetInt32(0));
                        }

                        LogStepPass();
                    }
                }

                LogTestStep("Test BatchExecute with null");
                try
                {
                    result = conn.BatchExecuteNoQuery(null);
                    Log("The expected exception is not thrown: Object reference not set to an instance of an object.");
                    LogStepFail();
                }
                catch (CUBRIDException ex)
                {
                    Log(ex.Message);
                    Assert.AreEqual("Object reference not set to an instance of an object.", ex.Message);
                    LogStepPass();
                }

                //revert the test db
                DBHelper.ExecuteSQL("drop table t;", conn);
                LogTestResult();
            }
        }
开发者ID:CUBRID,项目名称:cubrid-adonet,代码行数:52,代码来源:CUBRIDConnectionTest.cs

示例2: Test_BatchExecuteNoQuery

    /// <summary>
    /// Test CUBRIDConnection BatchExecuteNoQuery() method
    /// </summary>
    private static void Test_BatchExecuteNoQuery()
    {
      using (CUBRIDConnection conn = new CUBRIDConnection())
      {
        conn.ConnectionString = TestCases.connString;
        conn.Open();

        string[] sqls = new string[3];
        sqls[0] = "create table t(id int)";
        sqls[1] = "insert into t values(1)";
        sqls[2] = "insert into t values(2)";

        conn.BatchExecuteNoQuery(sqls);

        string sql = "select count(*) from t";
        using (CUBRIDCommand cmd = new CUBRIDCommand(sql, conn))
        {
          using (DbDataReader reader = cmd.ExecuteReader())
          {
            reader.Read();
            Debug.Assert(reader.GetInt32(0) == 2);
          }
        }

        TestCases.ExecuteSQL("drop table t", conn);
      }
    }
开发者ID:CUBRID,项目名称:cubrid-adonet,代码行数:30,代码来源:TestVarious.cs


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