Monday, March 12, 2012

how to handle "" in select statement?

How to handle last name like O'Connor, D'Avino?
If I use:
Select * from tblPeople where LastName = ' & strLName & '
I got error if strLName = O'Cononr

If you stick with this way of doing it (concatenation), you will need to double up the single quotes before you insert. Check out this tutorial:
http://aspnet101.com/aspnet101/tutorials.aspx?id=2
However, for many reasons (security being one of the most urgent), I'd suggest learning about parameterized queries - then, you don't need to worry about such stuff:
http://aspnet101.com/aspnet101/tutorials.aspx?id=1

Labels: , , , , , , , , , , ,

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home