August 14th, 2002, 01:41 AM
I have a text field which contains a ' (eg:Hero's)
If I do a Any SQL statment swith this THat will CRASH!!!!
WHat I can do is replace' with ''
But any any other alternative.
Thankx in advance.
August 14th, 2002, 02:10 AM
Where to you use it in your SQL statement ?
When you use it after LIKE or = you can do this :
... LIKE "Hero's" ... this will work.
If Hero's is a table name you better rename it.
I hope that will help you
August 14th, 2002, 02:14 AM
Say gv_strServer = Hero's Day
Insert Into Server (ServerName)
VALUES ('" & gv_strServer & ")"
August 14th, 2002, 02:32 AM
I try it and this work :
Set rsC = CurrentProject.Connection
strBu = "Hero's"
strSQL = "INSERT INTO ins VALUES(2,""" & strBu & """);"
rsA.Open strSQL, ActiveConnection:=rsC, CursorType:=adOpenDynamic, LockType:=adLockOptimistic
If rsA.State <> adStateClosed Then
Set rsA = Nothing
In your Statement i think the Number of " is wrong. Try this out.
I hope this will help you
August 14th, 2002, 06:49 AM
Replace all the one single quote with two single quotes. For example, Hero's becomes Hero''s (note the second one has two single quotes instead of a double-quote). You can easily do so by Replace(szStr, "'", "''").
I think anyway,
November 14th, 2003, 12:27 AM
One can suppress the apostrophe like this
Public Function Validateapostrophe(KA As Integer) As Integer
If KA = 39 Then
Validateapostrophe = 0
Validateapostrophe = KA
Fields("title")= Replace(TxtTitle.Text,"'", "!")
! - is a rarely used character so u can do with this one.
TxtTitle.Text = Replace(.Fields("title"), "!", "'") & ""
Hope this will help you
November 14th, 2003, 12:33 AM
I posted this question about one year back!!
Good to know that old discussion are viewed by people
But what will happen if my text contain !
November 14th, 2003, 02:49 AM
Coolbiz got it...
(An old question...)
As coolBiz said, trick is:
double ' chars
strSlq"Say hello to john's car"
This works for vb and sql server.
(out of context?)
Then you can have:
jsEncode = msgs & ""
jsEncode = Replace(jsEncode, "\", "\\")
jsEncode = Replace(jsEncode, "'", "\'")
JSEncode = Replace(JSEncode,"""",""",1,-1,1)
JSEncode = Replace(JSEncode,"<","<",1,-1,1)
JSEncode = Replace(JSEncode,">",">",1,-1,1)
jsEncode = Replace(jsEncode, vbCrLf, "\n")
jsEncode = Replace(jsEncode, vbLf, "\r")
jsEncode = Replace(jsEncode, vbTab, "\t")
<td><input id="rdCust" type="radio" size="20" name="rdCust" value='<%=tmpIDCustomer%>'
In every language you can find a way to encode what the language would think it is a "special" char, to make it consider it a "normal" one. You have only to find how...
...at present time, using mainly Net 4.0, Vs 2010
Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.