No offense, mmilan, but God, I'm tired of hearing "just double up the apostrophes" in response to these questions.
Doing this will leave your program open to a serious attack called SQL Injection. This vulnerability allows an attacker to do anything they want on your server, including formatting the C: drive. And all he has to do is fill out a field in your application correctly.
To avoid this, you need to use ADO parameters. Not only will this solve your apostrophe problems, but it will also prevent SQL Injection attacks, and even makes your program run faster!
Chip H.
____________________________________________________________________ If you want to get the best response to a question, please read FAQ222-2244 first
No offence at all Chip - your post was constructive, and therefore most welcome...
I didn't consider SQL injection, so nice catch...
However, the OP is wanting to deal with character literals - and that's the question I answered. I agree that in an ideal world all modification of code would be carried out under stored procedures, but for many of us who have walked into someone else's code pile, that's simply not an option.
Just so you guys know the "Unfortunately" was in response to it being a shame that in dealings with character literals that there isn't much else to do.
... you mean except to use ADO parameters in a command object, or use a parameter SP
________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'If we're supposed to work in Hex, why have we only got A fingers?'
I wasn't aware that you could use paramaters. In fact I posted a question some months ago and was told it couldn't be done. Now that I know how I will be changing all my code. Thanks
There are still a few times where you can't use parameters. A SQL "IN" clause is one of them. But otherwise, using parameters (while a lot more coding) will result in faster program execution because the database can put your statement in it's procedure cache. The next time you ask for it to be run, the database can pull it out of cache, and doesn't have to parse your SQL to check for validity (do metadata lookups to make sure all the columns & tables exist, check for syntax errors, etc), since it's already done that before.
Chip H.
____________________________________________________________________ If you want to get the best response to a question, please read FAQ222-2244 first
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.