Uploaded image for project: 'CUBRID APIs'
  1. CUBRID APIs
  2. APIS-152

[ODBC] 한글 쿼리 실행 시 에러

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Component/s: ODBC
    • Labels:
      None
    • Environment:

      Windows 2008
      CUBRID 2008 R4.0
      odbc 4.1

      Description

      사용자이슈 출처 : http://www.cubrid.com/zbxe/303618

      ADO.net 을 이용하여 C# 에서 select 할 시 한글로 where조건을 주면 결과가 나오지 않습니다.

      매니져에서 문제가 없는 커리문이 C#코드에서는 결과가 나오지 않습니다.

      ex >> SELECT * FROM member WHERE user_name='아무개';

      ODBC를 설정해서 다시 실행시 아래와 같은 에러 메시지가 나옵니다.

      ERROR [HY000] [CUBRID][ODBC CUBRID Driver][-1006]Server handle not found

      ERROR [01000] [CUBRID][ODBC CUBRID Driver][0]Fetch error

        Activity

        Hide
        ryin005 Ray Yin added a comment - - edited

        ODBC 9.1.0 (20130422-14175366) works properly for SQL queries whcih contains Korean

         
        //APIS-152
        [Test, Description("Test APIs issue 152 on ODBC-9.1.0")]
        public void ReviewIssueTest_APIs152()
        {
            string strConn = @"Driver={CUBRID Driver};db_name=odbc_test;uid=dba;pwd=;server=10.34.64.57;port=33037;fetch_size=100;charset=UTF-8;";
            OdbcConnection connCubrid = new OdbcConnection(strConn);
            connCubrid.Open();
        
            string korean_string = "아무개";
            string testTable = "test_apis152";
            string strCreateTable = string.Format("CREATE TABLE {0}(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, korean_string STRING)", testTable);
            string strDropTable = string.Format("DROP TABLE {0}", testTable);
            string strSqlInsert = string.Format("INSERT INTO {0}(korean_string) VALUE('{1}')", testTable, korean_string);
        
            ExecuteMultiQueries(connCubrid, new string[] { strDropTable, strCreateTable, strSqlInsert });
        
            string strSqlSelect = string.Format("SELECT * FROM {0} WHERE korean_string = '{1}';", testTable, korean_string);
            OdbcDataReader odbcReader = CreateReader(connCubrid, strSqlSelect);
            if (odbcReader.Read())
            {
                Assert.IsTrue(odbcReader.HasRows);
            }
        
            connCubrid.Close();
        }
        
        private OdbcDataReader CreateReader(OdbcConnection conn, string query)
        {
            OdbcCommand command = new OdbcCommand();
            command.Connection = conn;
            command.CommandText = query;
            OdbcDataReader odbcReader = command.ExecuteReader();
            odbcReader.Read();
            return odbcReader;
        }
        
        private void ExecuteMultiQueries(OdbcConnection conn, string[] multiQueries)
        {
            OdbcCommand command = new OdbcCommand();
            command.Connection = conn;
            foreach (string query in multiQueries)
            {
                try
                {
                    command.CommandText = query;
                    command.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            command.Dispose();
        }
        
        Show
        ryin005 Ray Yin added a comment - - edited ODBC 9.1.0 (20130422-14175366) works properly for SQL queries whcih contains Korean //APIS-152 [Test, Description("Test APIs issue 152 on ODBC-9.1.0")] public void ReviewIssueTest_APIs152() { string strConn = @"Driver={CUBRID Driver};db_name=odbc_test;uid=dba;pwd=;server=10.34.64.57;port=33037;fetch_size=100;charset=UTF-8;"; OdbcConnection connCubrid = new OdbcConnection(strConn); connCubrid.Open(); string korean_string = "아무개"; string testTable = "test_apis152"; string strCreateTable = string.Format("CREATE TABLE {0}(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, korean_string STRING)", testTable); string strDropTable = string.Format("DROP TABLE {0}", testTable); string strSqlInsert = string.Format("INSERT INTO {0}(korean_string) VALUE('{1}')", testTable, korean_string); ExecuteMultiQueries(connCubrid, new string[] { strDropTable, strCreateTable, strSqlInsert }); string strSqlSelect = string.Format("SELECT * FROM {0} WHERE korean_string = '{1}';", testTable, korean_string); OdbcDataReader odbcReader = CreateReader(connCubrid, strSqlSelect); if (odbcReader.Read()) { Assert.IsTrue(odbcReader.HasRows); } connCubrid.Close(); } private OdbcDataReader CreateReader(OdbcConnection conn, string query) { OdbcCommand command = new OdbcCommand(); command.Connection = conn; command.CommandText = query; OdbcDataReader odbcReader = command.ExecuteReader(); odbcReader.Read(); return odbcReader; } private void ExecuteMultiQueries(OdbcConnection conn, string[] multiQueries) { OdbcCommand command = new OdbcCommand(); command.Connection = conn; foreach (string query in multiQueries) { try { command.CommandText = query; command.ExecuteNonQuery(); } catch (Exception e) { Console.WriteLine(e.Message); } } command.Dispose(); }

          People

          • Assignee:
            cn15163 杨伟为[Astro]
            Reporter:
            jeongbin.lee Jeongbin Lee
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: