tags:

views:

38

answers:

3

i want to insert some text in mysql but text have double quote "" in middle of the text then insert query failed what i do in c# to solve this issue

Incorrect string value: '\xE0\xA4\x85\xE0\xA4\xAD...' for column 'colname' at row 1

ex: this is a simple "text"
A: 

Use a \ char to escape the quotes. So instead of " you will have \". For a longer, more realistic example, you might have something like:

"This string has quotes around \"this phrase\" but they are part of the value"

JGB146
A: 

use the escape character ('\') to escape the quotes so they can be interpreted literally.

Scott M.
+1  A: 

You can use query parameters. For example:

sql.command.Parameters.AddWithValue("?UserName", username);
sql.command.Parameters.AddWithValue("?Password", password);
sql.command.CommandText = "SELECT * FROM `users` WHERE `username`=?UserName
  AND `password`=?Password LIMIT 1"; 
thomasrutter