Timeline for OPENJSON unable to parse Chinese characters
Current License: CC BY-SA 3.0
7 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 24, 2017 at 10:41 | comment | added | Chee Hou Ng |
@Tomalak it works with the following code cmd.Parameters.Add("@JsonString", SqlDbType.NVarChar, -1); Thanks.
|
|
Oct 20, 2017 at 10:28 | comment | added | Tomalak |
This should work, .NET strings are Unicode and parameter datatypes are normally inferred properly. You can try adding the parameter with an explicit SqlDbType.NVarChar data type, like here: stackoverflow.com/a/1992741/18771.
|
|
Oct 20, 2017 at 10:28 | comment | added | Chee Hou Ng | sorry, I'm new at here, the code might look dirty, because I have no idea how to do newline in SO's comment section. | |
Oct 20, 2017 at 10:24 | comment | added | Chee Hou Ng |
@Tomalak Just a normal c# code: var serializer = new JavaScriptSerializer(); var JsonString = serializer.Serialize(List_EmpInfo); string connS = ConfigurationManager.ConnectionStrings["DB_Connn"].ConnectionString; SqlConnection connection = new SqlConnection(connS); SqlCommand cmd = new SqlCommand("SP_StoreEmpInfo", connection) { CommandType = CommandType.StoredProcedure }; cmd.Parameters.AddWithValue("@Json", JsonString);
|
|
Oct 20, 2017 at 7:41 | comment | added | Tomalak | @CheeHouNg How do you call the stored procedure? Show the code. | |
Oct 20, 2017 at 4:01 | comment | added | Chee Hou Ng | Sorry that I do not mention clearly, actually my JSON is a parameter inside a Stored Procedure. I cannot simply put an 'N' in front of it, if I try to do something like this: set JSON = 'N' + JSON I will hit an error, since the N will cause the an error of invalid JSON format. | |
Oct 20, 2017 at 3:45 | history | answered | TOBrien | CC BY-SA 3.0 |