views:

499

answers:

3

I have a problem wherein if I have a text area in ASP.NET and enter 2 double quotes at the very end of the sentence, I get a error in my sql statement. I have traced thru the sql profiler but with no luck.

eg. The lazy fox jump over the dog"". This fails....

""The "lazy" fox jumps over the dog. This seems fine

Any pointers most welcome

+3  A: 

Are you concatenating your user input into the SQL statement directly? If so, that's almost certainly the problem.

If you use a parameterised SQL statement instead (i.e. send the user data as a parameter rather than directly in the SQL) it should be fine. That way you also guard against SQL injection attacks...

Jon Skeet
+1  A: 
0x3A28213A 
0X6339392C 
0X7363682E
Telos
Plagiarized from XKCD, of course...
Telos
That'll be the problem then! Maybe he's using x64, so those 32-bit pointers won't work... <g>
Marc Gravell
+3  A: 

You should probably post the exact error message (and if possible, illustrative code). Also - note that with LINQ-to-SQL, you don't need the sql profiler to see the trace:

ctx.Log = Console.Out; // job done
Marc Gravell