Click here to Skip to main content
15,664,506 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to write the query like this

@"insert into MetersTest (a,b,c,d) values (@a,@b,@c,@d)"

I am not sure how to write the above query in the json.
"Query": @"insert into MetersTest (a,b,c,d) values (@a,@b,@c,@d)"

but the above json format is not correct .
Please suggest.

What I have tried:

   "Name": "TestName",
   "Query": "insert into MetersTest (a,b,c,d) values (@a,@b,@c,@d)",
   "Paramters": {
     "a": "a",
     "b": "b",
     "c": "c",
     "d": "d"
Updated 21-Sep-22 23:21pm
OriginalGriff 22-Sep-22 1:49am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with - we get no other context for your project.
Imagine this: you go for a drive in the country, but you have a problem with the car. You call the garage, say "it broke" and turn off your phone. How long will you be waiting before the garage arrives with the right bits and tools to fix the car given they don't know what make or model it is, who you are, what happened when it all went wrong, or even where you are?

That's what you've done here. So stop typing as little as possible and try explaining things to people who have no way to access your project!

And just saying "is not correct" doesn't help anyone since we have no idea what you are trying to do with it or why it doesn't do exactly what you want it to!

Use the "Improve question" widget to edit your question and provide better information.
Himansh jain 27-Sep-22 0:51am    
I am sorry, I will try to be more clear from the next time.

1 solution

"Query": @"insert into MetersTest (a,b,c,d) values (@a,@b,@c,@d)"
JSON files don't share C#'s "verbatim string[^]" construct. Strings must be delimited with double quotes, with no prefix, and any special characters within the string must be properly escaped.

Since there are no special characters in the string you're using, you just need to remove the @ prefix from the string literal:
"Query": "insert into MetersTest (a,b,c,d) values (@a,@b,@c,@d)"
The JSON in your "What I have tried" section is valid JSON. Since you haven't explained what's wrong it, we can't tell you how to fix it.
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