fiogf49gjkf0d You can escape a single quote with two consecutive single quotes.
For example, this will cause an error:
select * from contact where lastname = 'O'Brian'
But this will not:
select * from contact where lastname = 'O''Brian' --notice the two consecutive single quotes
You can use the VBScript function in your code to replace the single quote with two consecutive single quotes:
lastname = "O'Brian" sql = "select * from contact where lastname = '" & Replace(lastname, Chr(39), Chr(39) & Chr(39)) & "'" '...btw, Chr(39) is a single quote character
A better approach however, is to use a parameterized query and then use parameters for your values you need to plug into the query. Then things like single quotes are not an issue. |