Double quotes being replaced with ' + CHAR(34) + ' in SQL using ASP.NET

6.4k views Asked by At

I am using SQL Server 2008 Web Edition and it seems my SQL queries are automagically having the double quotes replaced with ' + CHAR(34) + '. I am trying to pin down why this is happening, I am using Delphi with ASP.NET and using the ADO.NET object for the SQL.

Has anyone come across this before?

2

There are 2 answers

0
webnoob On BEST ANSWER

It turns out that it isn't ASP.NET or Delphi causing the issue but is the editor I am using to allow the user to input data. It is replacing all the double quotes before spitting the content out to me.

1
Matt On

You could try escape them: Result = System.Text.RegularExpressions.Regex.Replace(InputTxt, @"[\000\010\011\012\015\032\042\047\134\140]", "\\$0");

EDIT: sorry, didn't realize you were using delphi. I'm sure the theory still applies even if the code doesn't.