on 11-05-2012 3:36 PM
Hi all!
I am trying to insert a data with single quote (') and I think this causes the command sql query for inserting the data to fail.
Is there a way on how to avoid this?
Thanks!
Hi Dru,
Inserting a string in SQL DB with single quote gives an error.But there are some cases where we cannot eliminate it and it becomes mandatory to insert a single quote.Just replace single quote ( ' ) with two single quotes (not a double quote).The first single quote is used as an escape character and only one single quote goes to the DB.
Hope it works..
Regards,
Anuj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dru,
This is an issue with the SQL side since a single tick mark (single quote) is used to specify a literal string. You can do a string replace for that property prior to passing the SQL to your database. What you replace it with will take some testing, but you will likely need to use escape characters recognized by your database. Or you can clean up the data and train the users to not use special characters, but that is like tilting at windmills in real life. (i.e. Don't bother trying to be Don Quixote).
Regards, Mike
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
6 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.