DataSet does not recognize LIKE and search parameters

3

Good evening.
I have a table in the MySql database and I am using a DataSet to handle it in my Windows Form project. The problem is that when I try to use a query with LIKE, it does not recognize the parameter I'm requesting.

SELECT nome FROM aluno WHERE aluno.RA LIKE '%@RA%'

Has anyone ever gone through something like this or do you know how I can solve this problem?
When I use it in Direct BD, it works perfectly ... Edit: Here's how to print my screen.

    
asked by anonymous 30.05.2017 / 01:02

1 answer

1

If the '% @ RA%' snippet should be replaced with the parameter you are about to report, leave it outside the single quotes.

Example:

string sql = "SELECT * FROM aluno where RA LIKE @RA";
cmd = new MySqlCommand(sql, stringConn);
cmd.Parameters.AddWithValue("@RA", "%" + variavel + "%");
    
30.05.2017 / 01:21