How do you allow clients to enter text that contains an apostrophe?
Thanks!since the udfunctions were invented, it's not more a problem.|||...my clients are having trouble entering data if it contains apostrophes. Here is the code that they are using:
sql = "INSERT INTO TrainingData (PartID, TrngDate, TimeDay, Effort, UnitMeas, Partners, Comments, DateSubmt) "
sql = sql & "VALUES (" & Session("partid") & ", '" & CDate(strDateRun) & "', '" & Request.Form("ampm") & "', " & CInt(strEffort)
sql = sql & ", '" & strUnitMeas & "', '" & Request.Form("partners") & "', '" & Request.Form("comments") & "', '" & Date & "')"
Set rs = conn.Execute(sql)
Set rs =Nothing
If the comments or partners field contains an apostrophe, we seem to have a problem. How should I modify my code?
Thanks for your time!!!!|||If you need to insert apostrophies in SQL, make it a double apostrophie.
Like...
Insert into Table (Field1) Values ('That''s That')
In VB, just use:
Replace(sSQL,"'","''")
Works like a charm
Hope this helps.
No comments:
Post a Comment