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

New Apostrophe Dilemma

Status
Not open for further replies.

Pandyon

Programmer
Feb 21, 2001
38
0
0
US
I've seen all these great posts on getting rid of the apostrophe before it goes into the database...

But what if I can't do that. What if there are already apostrophes in Names in fields of my database (access)?

For example, the last name "O'Connor" is already in my database many times, as are other names with apostrophes. I want the user to be able to search for "O'Conner" from an ASP page. I've tried using the Replace function but it doesn't work. Is there any way that I can do this?

Or do I have to go back into my database and change every apostrophe to double quotes?

I've got this site down pat, except for this one little devil I can't get past.

Thanks
 
You can run the search and replace function from access to replace all instances of o'conner, without doing it manually. Regards

Big Dave


** If I am wrong I am sorry, but i'm only trying to help!! **

 
I've done this with ADO Access.
The Replace function is the answer JUST as you put the O'CONNOR into the SQL statement. You can not use the Replace function on the entire SQL statement.
strSQLName = Replace(strName,"'","''")

The place for handling all special characters is in building the SQL search statement, not in pollutting the DB. Compare Code (Text)
Generate Sort in VB or VBScript
 
Another option is to use Command and Parameter objects, as the Parameter object handles that for you. <insert witticism here>
codestorm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top