Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7702695
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:17:09+00:00 2026-05-31T23:17:09+00:00

I have a code: CREATE TABLE IF NOT EXISTS Person ( name varchar(24) …

  • 0

I have a code:

CREATE TABLE IF NOT EXISTS Person
(
   name varchar(24) ...
)
CHARACTER SET utf8 COLLATE utf8_polish_ci;

This works OK in my application, but I read if someone put in name field a string that contains character wchich code is greater than 127, database will use 2 bytes (or more) to store this character. So i think, i will change character set to utf16:

CHARACTER SET utf16 COLLATE utf16_polish_ci;

But now when I run my application, exception apears: KeyNotFoundException. It apears exactly at these instructions:

MySqlCommand komenda = baza.Połączenie.CreateCommand ();
komenda.CommandText  = zapytanie;

MySqlDataReader dr = komenda.ExecuteReader (); // HERE, at execute reader method

if (dr.Read ()) ...

1) Anyone had similar problem? 2) Any idea how to use always 2 bytes/char in database field?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T23:17:10+00:00Added an answer on May 31, 2026 at 11:17 pm

    I’m not sure I understand why you’re converting from UTF-8 to UTF-16. I’m assuming you’re worried that any characters that require two bytes or more to store, won’t fit in a UTF-8 encoding. This is not the case. In MySQL UTF-8 values can be stored with one, two, or three bytes. Unicode points U+0000 to U+007F take 1 byte and points U+0080 to U+07FF take 2 bytes–this range covers the Polish alphabet. Since the majority of characters in the Polish alphabet take 1 byte to store you should probably stick with UTF-8 and save some memory. However, if you want to always use 2 bytes, at the cost of wasted space, you could stick with UTF-16.

    Here are some helpful links:

    Unicode support in MySQL: http://dev.mysql.com/doc/refman/5.6/en/charset-unicode.html

    Basic Unicode Overview : http://www.joelonsoftware.com/articles/Unicode.html

    As for the exception, and this is purely a guess, it may have something to do with trying to read data that is UTF-8 encoded as if it were UTF-16 encoded. Did you change the character set after you already had UTF-8 encoded data in your table?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have one table: CREATE TABLE IF NOT EXISTS `test` ( `firstname` varchar(100) NOT
I have a code like this c.execute('CREATE TABLE IF NOT EXISTS base (ID INTEGER
Suppose I have a table like: create table { id numeric(5,3), code varchar(10) }
I have a database table that looks like this: CREATE TABLE IF NOT EXISTS
I have a mysql table like this (sql): CREATE TABLE IF NOT EXISTS silver_and_pgm
Im trying to create a table with this code: CREATE TABLE IF NOT EXISTS
I have a table created using Python + Sqlite3 c.execute('CREATE TABLE IF NOT EXISTS
This is my table CREATE TABLE IF NOT EXISTS `results_stock_all` ( `Result_Id` varchar(50) NOT
I have a Recipe Table: CREATE TABLE IF NOT EXISTS `RECIPES` ( `recipes_id` int(11)
I have the following test-code: CREATE TABLE #Foo (Foo int) INSERT INTO #Foo SELECT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.