开发者

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);
            try
            {
                //Name of the entity goes into the first attribute of the AddObject method followed by the entity itself
                //INSERTING
             开发者_JS百科   dsc.AddObject("Jokes", NewJoke);
                dsc.BeginSaveChanges(insertJoke_Completed, dsc);
            }


You have to set the collation for Chinese on the column, I think. More... http://blogs.msdn.com/b/sqlazure/archive/2010/06/11/10023650.aspx

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜