Dataset does not recognize LIKE and search parameters

Asked

Viewed 53 times

3

Good night.
I have a table in the Mysql database and 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 am asking for.
Follows code:

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

Has anyone ever been through anything like it or knows how to solve this problem?
When I use in direct comics, it works perfectly... Edit: Here’s how to print my screen.

Segue ai print do que estou tentando fazer...

  • How’s the code? You can edit your question by putting it?

  • I have a Dataset file with the tables and among the Querys of this table (student) has this code.

  • Yes, but there isn’t a code example you can put in your question?

  • show table structure also please

1 answer

1


If the chunk '%@RA%' should be replaced by the parameter you will enter, leave it out of simple quotes.

Example:

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.