Reputation: 2150
Is there a way to use the @ character in a MySQL query from a C# .net program without using parametrised queries?
So for example in the following program
String s =
@"LOAD DATA LOCAL INFILE C:\foo.txt'
INTO TABLE Bar
(idFoo, @baa)
SET
baa = nullif(@baa,'')
";
MySqlCommand myCommand = new MySqlCommand(s, myConnection);
MySqlDataReader myReader = myCommand.ExecuteReader();
@baa is treated like a parameter. ie: as one would use when calling
myCommand.Parameters.Add("@baa", SqlDbType.VarChar );
However in this case I do not want @baa to be a parameter. How do I write this?
Upvotes: 0
Views: 89
Reputation: 16584
MySQL uses the back-tick character to quote tokens with spaces or other special characters. This is used for example to handle field names with spaces, etc.
So in your code, where you want @baa
to refer to a field name, place back-tick characters around the name like so: `@baa`
Upvotes: 1