2

I have Sql database with table name QUESTION.

I want to insert value for QuestionTitle as html string. Insert query is

INSERT INTO 
   QUESTION (QuestionType,QuestionID,QuestionTitle) 
VALUES ("MRQ",
        "QNB5T6TKDMS",
        "<p><span style="font-family: comic sans ms,sans-serif; font-size: 
small;">what was the original concentration of the acid?</span></p>")

When I try to execute this query in Sql it gives an error . How can I do this so that it will work for html string.

5
  • it give error as:[ near "font": syntax error ] Exception Name: NS_ERROR_FAILURE Commented Jun 26, 2014 at 6:31
  • extra " in your 3rd values. try to escape that. Commented Jun 26, 2014 at 6:35
  • You might want to check this question : Preventing SQL Injection in ASP.Net VB.Net : stackoverflow.com/questions/4018174/… Commented Jun 26, 2014 at 6:37
  • is it complusary to replace " with ' in insert statement at time of insert html value Commented Jun 26, 2014 at 6:38
  • @pallavi_ios check it once again.I have edited answer.we can use any type of quotes Commented Jun 26, 2014 at 6:40

2 Answers 2

4

You have error in using " inside the third inserted value

INSERT INTO 
   QUESTION (QuestionType,QuestionID,QuestionTitle) 
VALUES ('MRQ',
        'QNB5T6TKDMS',
        '<p><span style="font-family: comic sans ms,sans-serif; font-size: small;">
         what was the original concentration of the acid?</span></p>'
       );

You can also use escape slashes

Sign up to request clarification or add additional context in comments.

2 Comments

is it complusary to replace " with ' in insert statement
Yes.. You have to do that
0

Try somthiung like this:-

INSERT INTO QUESTION (QuestionType,QuestionID,QuestionTitle) VALUES 
('MRQ','QNB5T6TKDMS','<p><span style="font-family: comic sans ms,sans-serif; font-size: 
small;">what was the original concentration of the acid?</span></p>');

Hope this helps you.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.