问题
i've problem to insert hebrew strings to MySql.
Introduction
- I set the MySql to Utf8.
- I set the table as charset utf8 with collation uft8_general_ci
- I set the connection string as it: "Server=;Database=;Uid=;Pwd=; charset=utf8;"
- I write stored procedure for using it by c#.
- Version of MySql: 5.1.53
when i simply insert hebrew string to table by MySql as it :
insert into temp_table (temp_column) values ('ערך')
i saw as proper. if i set stored procedure as it..i see gibberish.
when i call it by c# i get exception as 'Incorrect string value: '\xD7\xAA\xD7\xA8...' for column...'
if i insert english strings, so i get all as proper.
any idea?
回答1:
You said you set the table as charset UTF8, but did you set the column encoding to UTF8 too ?
And/or try sending a SET NAMES utf8; command to MySql before executing your stored procedure.
SET NAMES indicates what character set the client will use to send SQL statements to the server. Thus, SET NAMES 'cp1251' tells the server, “future incoming messages from this client are in character set cp1251.” It also specifies the character set that the server should use for sending results back to the client. (For example, it indicates what character set to use for column values if you use a SELECT statement.)
回答2:
i added to stored procedure charset utf8
in SP_CityName VARCHAR(100) charset utf8, in SP_CitySynonyms mediumtext charset utf8
and now it works fine... thanks a lot to u all.
回答3:
Use Text/LongText instead of varchar. Also use Collation as utf8_general_ci
来源:https://stackoverflow.com/questions/4571044/problem-with-hebrew-mysql-c-sharp