c# - Trouble with single quotes in Select expression -


this question has answer here:

the code pretty simple:

string expression = "user = '" + user.username + "'"; int selectioncount = data.select(expression).count(); 

it works fine until user.username doesn't contain single quote '. example, if user.username equal "gul'mirka" app crashes. how fix this?

actually user.username can contain anything, numbers (7548375982) or mathematical equations (1 + x = 4).

thank you!

escape single quotes:

string expression = "user = \'" + user.username + "\'"; int selectioncount = data.select(expression).count(); 

Comments

Popular posts from this blog

java - How to specify maven bin in eclipse maven plugin? -

single sign on - Logging into Plone site with credentials passed through HTTP -

php - Why does AJAX not process login form? -