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

Replace quotations in SQL Access Query/Insert Statement 1

Status
Not open for further replies.

Godfrey

Programmer
Apr 10, 2003
9
US
Hi,

I need a function that will properly quote for insertion an SQL (for Access DB) statement. I currently have one that works for a single Apostrophe:

Public Function ApostropheCheck(ByVal strIn As String)

ApostropheCheck = Replace(strIn, "'", "''")
Exit Function

End Function

Can you help me with one that will do exactly the same as above except instead of replacing ' --it will replace all " ?

Thank you!
 
Public Function QuoteCheck(ByVal strIn As String)

QuoteCheck = Replace(strIn, """", """""")
Exit Function

End Function

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
You generally don't want to do this, as it leaves you open to a SQLInjection attack (google the term for some shocking info). Instead, you should use ADO parameter objects.

Chip H.


____________________________________________________________________
Donate to Katrina relief:
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top