IonicWind Software

IWBasic => Database => Topic started by: billhsln on October 04, 2007, 12:29:54 PM

Title: Storing Last Name with name like O'Henry
Post by: billhsln on October 04, 2007, 12:29:54 PM
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.
Title: Re: Storing Last Name with name like O'Henry
Post by: pistol350 on October 04, 2007, 01:12:50 PM
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  :)
Title: Re: Storing Last Name with name like O'Henry
Post by: ExMember001 on October 04, 2007, 01:56:51 PM
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 ;)
Title: Re: Storing Last Name with name like O'Henry
Post by: pistol350 on October 04, 2007, 02:25:49 PM
yÃÆ'Ã,©p!
That explanation sets things clearer.
Thanks krypt for enlighten (me/us) ;)
Title: Re: Storing Last Name with name like O'Henry
Post by: billhsln on October 04, 2007, 02:30:56 PM
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