April 19, 2024, 06:27:28 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Storing Last Name with name like O'Henry

Started by billhsln, October 04, 2007, 12:29:54 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

billhsln

October 04, 2007, 12:29:54 PM Last Edit: October 04, 2007, 12:32:38 PM by billhsln
When I try to do an insert into a table with LastName = O'Henry, my query aborts.  Is there another way to do this or should I change the "'" (Single Quote) character to something else and then do the insert?

Will INSERT allow LastName="O'Henry", or does it have to be LastName='O''Henry'?

Thanks,
Bill

PS, I know it would be easier to just ignore the quote, but some people get upset when their name is not spelled correctly as they want it.
When all else fails, get a bigger hammer.

pistol350

Hi Bill!
I 'm not a Guru when it comes to deal with database, so i may not have the proper solution.
But according to what i understood, there is something wrong when you enter "O'Henry", so your query aborts.
First, to me "O'Henry" is just a full string as "The cat is sleeping near on the sofa" ::) or as "John" so the problem might not be there.Just my suggestion though.
Anyway,please post a piece of code so that we can dig deeper  :)
Regards,

Peter B.

ExMember001

the problem is the apostrophe, most database can't use them as data ...
you need to replace them with something else and backward to retreive.
some database use something like "\'" because ' is use as in db->query('SELECT FROM ECT...') if you set an ' there it cut the string ;)

pistol350

yÃÆ'Ã,©p!
That explanation sets things clearer.
Thanks krypt for enlighten (me/us) ;)
Regards,

Peter B.

billhsln

I added the following code, to change all single quotes to 2 single quotes, hoping this will allow the name to go thru correctly.  Found this solution on a web site for SQL problems.



x = instr(LastName,"'")
if x = 0
    fLastName = LastName
else
fLastName = ""
for x = 1 to len(LastName)
c = mid$(LastName,x,1)
if c = "'" then c = "''"
fLastName += c
next x
endif


Thanks for the help,
Bill
When all else fails, get a bigger hammer.