Dictionary Data to insert in Database

I have a dictionary(String, String) which has values and those values are to be inserted in a DB table. I’m using a insert-into statement using Run Query activity, but it results in a compiler error. Is the below code correct.?

INSERT Into tradebot.share_details
VALUES(’ “+dictionary_Data(“customer_id”).ToString+” ',
’ “+dictionary_Data(“price”).ToString+” ');


It looks correct…can you show a screenshot of error and the syntax


Hi @automated

Your query is perfect, but you are better to change the single quotes and double quotes, could you check out the below query,

INSERT INTO tradebot.share_details (customer_id, price) VALUES ('" 
    + dictionary_Data["customer_id"].ToString() + "', '" 
    + dictionary_Data["price"].ToString() + "');

Hope it helps!!

My insert query in the ‘Run query’ activity is as below.
The error says “String query must end with double quotes”. Kindly suggest what changes are to be done.

"INSERT INTO bot.credit_details VALUES
’ “+dictionary_Data(“credit_id”).ToString+” ',
’ “+dictionary_Data(“description”).ToString +” ',
’ “+dictionary_Data(“start_date”).ToString+” ',
’ “+dictionary_Data(“end_date”).ToString +” ',
’ “+dictionary_Data(“submit_date”).ToString+” ',
’ “+dictionary_Data(“submitter”).ToString+” ',
’ “+dictionary_Data(“priority”).ToString+” ',
’ “+dictionary_Data(“service_type”).ToString+” '); "

It’s not working, still says that the string query must end with double quotes.

What’s in the data? If there is a single quote in description then it’ll break the quote pairs.

What you should do is assign that to a variable then output the variable with a Log Message so you can see the final actual resulting query.

Also, when you paste code into a comment here, you should highlight it and click the </> button in the toolbar. That way it won’t alter the fonts. It appears that you have the wrong double quote characters, but that could just be because this forum is changing them when you post.

Dictionary is (String,String) type. I tried various possibilities of quotes, resulting in same error message, “String constant should end with double quotes.”

I’m talking about the VALUE that’s in the dictionary.

If description has a value of “Mike’s computer” then when you do "field='" + currentRow("Description").ToString + "'" you’ll end up with…

field='Mike's computer'

And that breaks the query because of the single quote in Mike’s.