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 sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving Names with Single Quotation Mark Problem

Status
Not open for further replies.

TJLearn

Programmer
Dec 6, 2003
12
US
Hi,

I'm having a problem with my INSERT statement when the name on a text box is including a single quotation mark. The name is O'Kelly

My insert statement is:

Dim sql AS string

sql = "insert into LoanAgent "
sql = sql & "(LName) values "
sql = sql & "('" & txt.LName & "')"

Any help is very appreciated.

 
Try this modification for the sql statement:
Code:
sql = "insert into LoanAgent "
sql = sql & "(LName) values "
sql = sql & "(""" & txt.LName & """)"
 
You can also try replace this:
sql = sql & "('" & txt.LName & "')"
By this:
sql = sql & "('" & Replace(txt.LName, "'", "''") & "')"

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top