sunxin8086 sunxin8086 - 1 year ago 62
SQL Question

Insert chinese using odata client to azure sql

I am using azure aql as a backend for a windows phone app I am writing. I expose the db using odata protocol, and using the odata client library to read and write db. I am having a problem to insert Chinese strings. Each chinese charatcter will show up as "?" in the db.
The following is the code. Using the debugger, i can tell, the chinese character is still in the write format before the BeginSaveChanges call. The according field in the db is defined as nvarchar. I can put chinese no problem from the web management portal.

NewJoke.Title = Regex.Replace(NewJoke.Title, "'", "''");
NewJoke.Content = Regex.Replace(NewJoke.Content, "'", "''");
dsc = new DataServiceContext(funnyJokesUri);
//Name of the entity goes into the first attribute of the AddObject method followed by the entity itself
dsc.AddObject("Jokes", NewJoke);
dsc.BeginSaveChanges(insertJoke_Completed, dsc);

Answer Source

You have to set the collation for Chinese on the column, I think. More...

BTW -- I wasn't clear on reading your question -- it sounds like you're saying the db stores the chinese fine when you use the web portal to insert it; but presumably, it does not store the chinese when you use some other method for inserting it. (?) Is that what you're saying?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download