예제 #1
0
        /// <summary>
        /// Test CUBRIDDataReader getter methods
        /// </summary>
        private static void Test_DataReader_Getxxx()
        {
            using (CUBRIDConnection conn = new CUBRIDConnection())
            {
                conn.ConnectionString = TestCases.connString;
                conn.Open();

                string sql = "select * from nation;";
                using (CUBRIDCommand cmd = new CUBRIDCommand(sql, conn))
                {
                    using (CUBRIDDataReader reader = (CUBRIDDataReader)cmd.ExecuteReader())
                    {
                        reader.Read();

                        Debug.Assert(reader.GetOrdinal("code") == 0);
                        Debug.Assert(reader.GetName(0) == "code");
                        Debug.Assert(reader.GetColumnName(0) == "code");
                        Debug.Assert(reader.GetColumnType(0) == typeof(System.String));
                        Debug.Assert(reader.GetDataTypeName(0) == "CHAR");
                    }
                }
            }
        }
예제 #2
0
        public void DataType_MultiSet_Test()
        {
            using (CUBRIDConnection conn = new CUBRIDConnection())
            {
                conn.ConnectionString = DBHelper.connString;
                conn.Open();

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

                DBHelper.ExecuteSQL("CREATE TABLE testtable(clsid multiset_of(INTEGER));", conn);

                using (CUBRIDCommand cmd = new CUBRIDCommand("Select * from TestTable", conn))
                {
                    using (CUBRIDDataReader reader = (CUBRIDDataReader)cmd.ExecuteReader())
                    {
                        reader.Read();

                        Assert.AreEqual(reader.HasRows, false);
                        Assert.AreEqual(reader.GetColumnType(0), typeof(Object[]));
                        Assert.AreEqual(reader.GetColumnTypeName(0), "MULTISET");

                        try
                        {
                            reader.GetColumnName(-1);
                        }
                        catch (Exception ex)
                        {
                            Assert.IsTrue((ex as IndexOutOfRangeException) != null);
                        }

                        try
                        {
                            reader.GetColumnTypeName(-1);
                        }
                        catch (Exception ex)
                        {
                            Assert.IsTrue((ex as IndexOutOfRangeException) != null);
                        }

                        try
                        {
                            reader.GetColumnTypeName(2);
                        }
                        catch (Exception ex)
                        {
                            Assert.IsTrue((ex as IndexOutOfRangeException) != null);
                        }

                        try
                        {
                            reader.GetColumnType(-1);
                        }
                        catch (Exception ex)
                        {
                            Assert.IsTrue((ex as IndexOutOfRangeException) != null);
                        }

                        try
                        {
                            reader.GetColumnType(2);
                        }
                        catch (Exception ex)
                        {
                            Assert.IsTrue((ex as IndexOutOfRangeException) != null);
                        }
                    }
                }

                DBHelper.ExecuteSQL("drop TestTable;", conn);
            }
        }