private static void TestGetData()
        {
            using (CUBRIDConnection conn = new CUBRIDConnection())
            {
                conn.ConnectionString = TestCases.connString;
                conn.Open();

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

                string sql = "create table t(";
                sql += "c_integer_ai integer AUTO_INCREMENT, ";
                sql += "c_smallint smallint, ";
                sql += "c_integer integer, ";
                sql += "c_bigint bigint, ";
                sql += "c_numeric numeric(15,1), ";
                sql += "c_float float, ";
                sql += "c_decimal decimal(15,3), ";
                sql += "c_double double, ";
                sql += "c_char char(1), ";
                sql += "c_varchar character varying(4096), ";
                sql += "c_time time, ";
                sql += "c_date date, ";
                sql += "c_timestamp timestamp, ";
                sql += "c_datetime datetime, ";
                sql += "c_bit bit(32), ";
                sql += "c_varbit bit varying(4096), ";
                sql += "c_monetary monetary, ";
                sql += "c_string string";
                sql += ")";
                ExecuteSQL(sql, conn);

                sql  = "insert into t values(";
                sql += "1, ";
                sql += "11, ";
                sql += "111, ";
                sql += "1111, ";
                sql += "1.1, ";
                sql += "1.11, ";
                sql += "1.111, ";
                sql += "1.1111, ";
                sql += "'a', ";
                sql += "'abcdfghijk', ";
                sql += "TIME '13:15:45 pm', ";
                sql += "DATE '00-10-31', ";
                sql += "TIMESTAMP '13:15:45 10/31/2008', ";
                sql += "DATETIME '13:15:45 10/31/2008', ";
                sql += "B'0110011110101001', ";
                sql += "B'010110110111110000', ";
                sql += "123456789, ";
                sql += "'qwerty'";
                sql += ")";
                ExecuteSQL(sql, conn);

                sql = "select * from t";
                using (CUBRIDCommand cmd = new CUBRIDCommand(sql, conn))
                {
                    CUBRIDDataReader reader = (CUBRIDDataReader)cmd.ExecuteReader();
                    Thread.CurrentThread.CurrentCulture   = CultureInfo.CreateSpecificCulture("en-US");
                    Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");
                    while (reader.Read()) //only one row will be available
                    {
                        int Ordinal = reader.GetOrdinal("c_integer_ai");
                        Debug.Assert(Ordinal == 0);

                        try
                        {
                            Guid guid = reader.GetGuid(0);
                        }
                        catch (Exception e)
                        {
                            string error = e.ToString();
                            Debug.Assert(e.Message == "Value does not fall within the expected range.");
                        }

                        try
                        {
                            Guid guid = reader.GetGuid(9);
                        }
                        catch (Exception e)
                        {
                            string error = e.ToString();
                            Debug.Assert(e.Message == "Guid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx).");
                        }

                        int  i = reader.GetInt32(0);
                        Type t = reader.GetColumnType(0);
                        Debug.Assert(i == 1);

                        short s = reader.GetInt16(1);
                        t = reader.GetColumnType(1);
                        Debug.Assert(s == 11);

                        i = reader.GetInt32(2);
                        t = reader.GetColumnType(2);
                        Debug.Assert(i == 111);

                        long i64 = reader.GetInt64(3);
                        t = reader.GetColumnType(3);
                        Debug.Assert(i64 == 1111);

                        decimal d = reader.GetDecimal(4);
                        t = reader.GetColumnType(4);
                        Debug.Assert(d == (decimal)1.1);

                        float f = reader.GetFloat(5);
                        t = reader.GetColumnType(5);
                        Debug.Assert(f == (float)1.11);

                        d = reader.GetDecimal(6);
                        t = reader.GetColumnType(6);
                        Debug.Assert(d == (decimal)1.111);

                        double db = reader.GetDouble(7);
                        t = reader.GetColumnType(7);
                        Debug.Assert(db == (double)1.1111);

                        char c = reader.GetChar(8);
                        t = reader.GetColumnType(8);
                        Debug.Assert(c == 'a');

                        string str = reader.GetString(9);
                        t = reader.GetColumnType(9);
                        Debug.Assert(str == "abcdfghijk");

                        DateTime dt = reader.GetDateTime(10);
                        t = reader.GetColumnType(10);
                        Debug.Assert(dt.Second == 45);

                        dt = reader.GetDateTime(11);
                        t  = reader.GetColumnType(11);
                        string dt_s = reader.GetDate(11);
                        Debug.Assert(dt == new DateTime(2000, 10, 31));

                        dt   = reader.GetDateTime(12);
                        t    = reader.GetColumnType(12);
                        dt_s = reader.GetDate(12, "yyyy-MM-dd");
                        dt_s = reader.GetTimestamp(12);
                        dt_s = reader.GetTimestamp(12, "yyyy-MM-dd HH:mm:ss.fff");
                        Debug.Assert(dt == new DateTime(2008, 10, 31, 13, 15, 45));

                        dt   = reader.GetDateTime(13);
                        t    = reader.GetColumnType(13);
                        dt_s = reader.GetTime(13);
                        dt_s = reader.GetTime(13, "HH:mm:ss");

                        Debug.Assert(dt == new DateTime(2008, 10, 31, 13, 15, 45));

                        byte[] by       = new byte[4];
                        byte[] expected = { 0x67, 0xa9, 0x00, 0x00 };
                        reader.GetBytes(14, 0, by, 0, 4);
                        Debug.Assert(by.SequenceEqual(expected));
                        t = reader.GetColumnType(14);

                        expected[0] = 0x5b; expected[1] = 0x7c; expected[2] = 0x00;
                        reader.GetBytes(15, 0, by, 0, 3);
                        Debug.Assert(by.SequenceEqual(expected));
                        t = reader.GetColumnType(15);

                        Debug.Assert(reader.GetString(16) == "123456789.0000000000000000");
                        t = reader.GetColumnType(16);
                        char[] buffer = new char[16];
                        reader.GetChars(16, 0, buffer, 0, 16);
                        Debug.Assert(reader.GetString(17) == "qwerty");
                        t = reader.GetColumnType(17);
                    }
                }

                ExecuteSQL("drop table t", conn);
            }
        }
        public void DataReader_GetChars_Test()
        {
            //TODO test date time
            using (CUBRIDConnection conn = new CUBRIDConnection())
            {
                Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-US");
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

                conn.ConnectionString = DBHelper.connString;
                conn.Open();

                DBHelper.ExecuteSQL("drop table if exists t", conn);
                DBHelper.ExecuteSQL("create table t (c varchar(100))", conn);
                DBHelper.ExecuteSQL("insert into t values ('abcdefghijklmn')", conn);
                DBHelper.ExecuteSQL("insert into t values ('opq')", conn);

                long   result      = 0;
                char[] resultArray = { '1', '2', '3', '4', '5', '6', '7', '8', '9' };

                string sql = "select * from t order by c";
                using (CUBRIDCommand cmd = new CUBRIDCommand(sql, conn))
                {
                    using (CUBRIDDataReader reader = (CUBRIDDataReader)cmd.ExecuteReader())
                    {
                        reader.Read();
                        result = reader.GetChars(0, 2, resultArray, 3, 4);
                        char[] expected = { '1', '2', '3', 'c', 'd', 'e', 'f', '8', '9' };

                        Assert.AreEqual(4, result);
                        for (int i = 0; i < resultArray.Length; i++)
                        {
                            Assert.AreEqual(expected[i], resultArray[i]);
                        }

                        try
                        {
                            result = reader.GetChars(1, 2, resultArray, 3, 4);
                        }
                        catch (IndexOutOfRangeException ex)
                        {
                            Assert.AreEqual("Index was outside the bounds of the array.", ex.Message);
                        }

                        try
                        {
                            result = reader.GetChars(0, 20, resultArray, 3, 4);
                        }
                        catch (IndexOutOfRangeException ex)
                        {
                            Assert.AreEqual("Data offset must be a valid position in the field!", ex.Message);
                        }

                        try
                        {
                            result = reader.GetChars(0, 2, resultArray, 10, 4);
                        }
                        catch (IndexOutOfRangeException ex)
                        {
                            Assert.AreEqual("Buffer index must be a valid index in buffer!", ex.Message);
                        }

                        try
                        {
                            result = reader.GetChars(0, 2, resultArray, 3, 9);
                        }
                        catch (ArgumentException ex)
                        {
                            Assert.AreEqual("Buffer is not large enough to hold the requested data!", ex.Message);
                        }


                        resultArray = new char[] { '1', '2', '3', '4', '5', '6', '7', '8', '9' };
                        // read opq
                        reader.Read();

                        try
                        {
                            result = reader.GetChars(0, 1, resultArray, 2, 4);
                        }
                        catch (ArgumentOutOfRangeException ex)
                        {
                            Assert.AreEqual(@"Index and count must refer to a location within the string.
Parameter name: sourceIndex", ex.Message);
                        }
                    }
                }

                //revert test db
                DBHelper.ExecuteSQL("drop table if exists t", conn);
            }
        }