Click here to Skip to main content
15,923,006 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am inserting data from C# to sql. I have taken json output in string object. json is like

{'data': '{"Code": "MXXXXX", "Status": "failed"}'}

How can I add json data into sql?

What I have tried:

insert into table1 (jsonscript) values ({'data': '{"UUI": "MXXXXX", "DialStatus": "answered"}'})
Posted
Updated 7-Feb-17 20:07pm

1 solution

Try putting quotes around the json string when using in code:
insert into table1 (jsonscript) values ("{'data': '{'Code': 'MXXXXX', 'Status': 'failed'}'}")

Also make sure you either escape your double quotes if you have them in the string :
"{\"data\": \"{\"Code\": \"MXXXXX\", \"Status\": \"failed\"}\"}"
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900