tags:

views:

58

answers:

2

Does anybody have any good .NET functions they can share to escape necessary MySQL query characters?

Thanks!

+7  A: 

Shouldn't you be using the MySQL Connector/NET? If you need to do something like parameterized queries, then it should provide "safe" and correct ways to do it, e.g. in this example.

bobbymcr
A: 

Could you give an example of the necessary characters? Without a context...you could try using "@" to give a literal string.

string query= @"select * from table"

Otherwise there is String.Replace().

Michael Baker
A C# literal string won't escape any MySQL-specific characters. It's a compile-time thing for C# with no effect whatsoever on any runtime parts.
Joey