PlayHardGoPro
PlayHardGoPro

Reputation: 2923

Using parameter into a select query

I have this query, which works perfect in the codeline and in my MySQL Manager:

SELECT field1, field2, field3
FROM Mytable
WHERE date_start >= STR_TO_DATE(' 01/07/2014 ', '%d/%m/%Y')  

Now, in the CodeBehind using parameter it doesn't return a single row...

sql = @"SELECT field1, field2, field3
    FROM Mytable
    WHERE date_start >= STR_TO_DATE('@data', '%d/%m/%Y')"

MySQLCOMMAND.Parameters.Add(new MySqlParameter("@data", MySqlDbType.Date)).Value = data;  

Where data = 01/07/2014.

Why it doesn't work with parameter?

Upvotes: 0

Views: 72

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269493

Your parameter is already a date. You don't need to convert it:

SELECT field1, field2, field3
FROM Mytable
WHERE date_start >= @data;

Upvotes: 1

Related Questions