|
-
February 11th, 2008, 09:55 AM
#1
[RESOLVED] Help with SQL in C#
Hello everyone,
I have a piece of code here that doesn't appear to work, and I think I know why, but I just can't get my head around a way to fix it. I'm am making a select statement from a database and doing a string comparison:
<code>
comm.CommandText = "SELECT Insurance_Company_Number, Insurance_Company_Name FROM TABLE_Insurance_Company WHERE Insurance_Company_Number = 'Hudson's Bay Co (Toronto)'";
</code>
Now, I'm certain the problem arises because of the apostrophe in Hudson's screwing around with the string, is there an escape sequence that I can use to use the ' as part of the string?
The error that comes up is:
Syntax Error (missing operator) in query expression 'Insurance_Company_Number = 'Hudson's Bay Co (Toronto)"
-
February 11th, 2008, 10:12 AM
#2
Re: Help with SQL in C#
The code tags actually use [] not <>.
The escape in SQL is the apostrophe. So, in your string you would need to do two apostrophe's in order to escape it.
-
February 11th, 2008, 10:19 AM
#3
Re: Help with SQL in C#
Thanks for the help, seemed to get the job done.
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
|