|
-
Jan 31st, 2008, 07:57 AM
#1
Thread Starter
Addicted Member
[RESOLVED] problem inserting/updating
Hello,
I get a syntax error when insurting,updating my database if a user uses an apostrophie.
ie: there's
i seem to remember at college they told us there was somthing you could put after the string to remove the apostrophies but i cant for the life of me remember what it was!
does anyone out there know how to remedy my problem???
any help woulod be great!
thanks,
Iain
-
Jan 31st, 2008, 08:09 AM
#2
Addicted Member
Re: problem inserting/updating
Can you tell the DB that you are using???. If its MSAccess / SQL Server you need to use the square brackets like.... [world's].
Last edited by cheenu_vasan; Jan 31st, 2008 at 08:21 AM.
Regards
Srinivasan Baskaran
India
-
Jan 31st, 2008, 08:15 AM
#3
Thread Starter
Addicted Member
Re: problem inserting/updating
how i'm doing it is the user fills in a richtext box in my .net program the data they have entered is given to a string vairable and this vairable is entered into the database via an sql command.
if i put a square round my vairable it will insert the whole string and not mess of because of the apostrophes?
-
Jan 31st, 2008, 08:25 AM
#4
Addicted Member
Re: problem inserting/updating
Try using the Double single quote for having single quote in your data.
Try searching your text for single singlequote and replace it with double singlequote
Regards
Srinivasan Baskaran
India
-
Jan 31st, 2008, 08:47 AM
#5
Re: problem inserting/updating
We could probably write a book just on how many times this particular question has been asked.
If you do a search on this subject, you will get a ton of returns and answers. In addition, I believe this is covered in our Database FAQs.
-
Jan 31st, 2008, 08:54 AM
#6
Thread Starter
Addicted Member
Re: problem inserting/updating
i'm not sure how i go about searing my string and replacing the apostrophe with a double single quote.
could you please post an example
-
Jan 31st, 2008, 09:02 AM
#7
Re: problem inserting/updating
Actually it's better if you don't do that.. it only solves one of the potential problems, and it is very hard to tell what the others may be (it varies by database system and various other factors).
The safest way to go is to use a Command object and put the values in via Parameters, which will also solve all of those other issues for you (without you even knowing what they are!). jmcilhinney posted an example in another one of your threads, here
As a bonus, you don't need to worry about delimiters or formatting dates etc, as it will automatically fill them in for you, as appropriate for the database system you are connected to!
-
Jan 31st, 2008, 09:35 AM
#8
Thread Starter
Addicted Member
Re: problem inserting/updating
Thank you all very much for your help!
Got it sorted now
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|