problem with hebrew - MySql, c#

无人久伴 提交于 2019-12-24 05:11:20

问题


i've problem to insert hebrew strings to MySql.

Introduction

  1. I set the MySql to Utf8.
  2. I set the table as charset utf8 with collation uft8_general_ci
  3. I set the connection string as it: "Server=;Database=;Uid=;Pwd=; charset=utf8;"
  4. I write stored procedure for using it by c#.
  5. 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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!