Link to home
Start Free TrialLog in
Avatar of arichexe
arichexe

asked on

handling glitches in sql string

I need to include glitches within a query string, but keep getting an "unterminated string" error.  How would I modify the below to accept glitches within the Name field?

Set conn = CreateObject("ADODB.Connection")
conn.Open MSSqlConnStr

MyName = "O'Brien"

MySql = "SELECT * FROM MyTable WHERE Name = '" & MyName & "'"

Set rs = conn.Execute(MySql)

If Not rs.EOF Then MsgBox("Found Name!")

rs.Close
conn.Close
ASKER CERTIFIED SOLUTION
Avatar of dancebert
dancebert

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial