|
-
Apr 19th, 2006, 05:01 PM
#1
Thread Starter
Member
[RESOLVED] SQL INSERT with apostrophes
I am coding in Visual Basic .NET, and using Visual Studio .NET 2003. I am working with SQL Server 2005 Express.
I'm trying to insert strings among other things into a database I have created. The problem is when I try to insert a string with an apostrophe in it (i.e. "Let's go") I'm having issues because the SQL command ends up looking something like this:
INSERT INTO table1('Let's go')
As you can see the apostrophe messes up my quotes, I've tried using double quotes but they won't work :/
I was looking into converting the string into unicode or something similar, but is there an easier way around this?
Last edited by JSand4325; Apr 20th, 2006 at 12:18 AM.
-
Apr 19th, 2006, 05:11 PM
#2
Re: [02/03] SQL INSERT with apostrophes
Don't use double-quotes, use two single-quotes. 
Code:
INSERT INTO table1('Let''s go')
(I'm afraid I dont know the .Net code to add the extra single quote)
-
Apr 19th, 2006, 05:23 PM
#3
Re: [02/03] SQL INSERT with apostrophes
stringname.replace("'","''")
Or just use parameterized queries/stored procs.
-
Apr 20th, 2006, 12:18 AM
#4
Thread Starter
Member
Re: [02/03] SQL INSERT with apostrophes
thanks I used the replace method for now. I don't know if parameterized queries could apply to what I'm doing, but I'll do more research on them when I'm going over this with a fine tooth comb.
Thanks again!
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
|