by far the better solution is to use parameters.
here a tutorial: www.csharp-station.com/Tut
you can go back and forth in the tutorial
Main Topics
Browse All TopicsHi All,
I have several text fields in a database table where it is probably that at some time someone will put double quotes in the text. Since the data in sql queries is delimited by double quote characters, double quotes in the text data causes the query to fail. The below code is the sub that generates and runs the query.
Is there any way to get around this short of modifying the text to delete double quotes or make them two double quotes which the query seem to handle?
Thanks
dr_roose
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
by far the better solution is to use parameters.
here a tutorial: www.csharp-station.com/Tut
you can go back and forth in the tutorial
You have toi be carefull witht he single quotes, usually with last names as you might see something like "O'Connor" as a name.
Another alternative which gets around this is to use the Chr$() function to supply the quote:
Dim sql As String
sql = "UPDATE contacts SET first = " & chr$(34) TB1.Text & chr$(34) & ", last = " & chr$(34) & TB2.Text & chr$(34) &
etc.
JimD.
Business Accounts
Answer for Membership
by: dougaugPosted on 2009-08-20 at 21:02:48ID: 25149071
Depending on what database you are using, you can enclosing strings in single quotes (only if your fields don't have single quotes in their values).
Regards
Select allOpen in new window