locked
Syntax error (missing operator) in query expression RRS feed

  • Question

  • User186553308 posted

    Hi..

    I'm having problem in inserting text from a textbox in which user write or copy some text which may contain special characters ( " , . ) etc. If there is any special character it get conflict with CommandText Syntax and generates error in inserting. I want to insert all these characters. How could i do it?

     

    Code:

            cmd.CommandText = "insert into funzone values ('" + txtfun.Text + "','" + txtname.Text + "')";
            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();

     

    CommandText After Build:

    CommandText "insert into funzone values ('There is a nice quote, \"Great power comes' with great responsibility\".','SiD')" string

    Sunday, August 8, 2010 10:55 AM

Answers