Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Workign with the tick in an SQL statement

Status
Not open for further replies.

MagnusFox

IS-IT--Management
Jan 12, 2001
51
US
Good day,

I have read the answer to this before but could not find it, nor remember the solution. So...

The [Field] is [LastName]
The <value> is <O'Mally>

The issue is the tick (')

When I run the following query, it returns: Syntax error (missing operator). I'm sure this is because the tick causes the SQL statement to fail.

rst.Open &quot;SELECT * FROM Person WHERE LastName='O'Mally';&quot;

How do I write O'Mally to the DB correctly so I can find it later without the above issue? How do I read O'Mally from the DB without receiving the above issue?

Many thanks,
Magnus
 
dim lastname
lastname = &quot;O'Mally&quot;

rst.Open &quot;SELECT * FROM Person WHERE LastName='&quot; & lastname & &quot;';&quot;

to store it in the db:

conn.execute &quot;UPDATE Person SET LastName='&quot; & Replace(lastname, &quot;'&quot;, &quot;''&quot;) & &quot;';&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top