You have not provided enough information to get any useful help.
(You might have figured that out yourself from the comments)
You need to realize that no one can execute your code. We don't know which database your are using in the first place.
Therefor, leaving out crucial information like where the variable connect is declared and initialized doesn't make it easy to give a good answer. (might it be db_connect?)
You also need to provide the error message you get, if any, otherwise it is impossible to help you figure out what is going wrong.
In order to solve your problem you need to use the debugger and set a break point at the first line in the method.
Then you step through the code and see what happens with your variables and statements.
1. The first thing I would check is to see if the variable connect has a value != null.
2. Then you need to make sure that your SQL statement actually gives back any result.
(is the statement
if (dr.Read()) ever entered.
At last.
It is always bad to use concatenated SQL commands, due to the vulnerability to SQL injection attacks. See
SQL injection - Wikipedia, the free encyclopedia[
^]
Use parameterized queries instead. See for example
MySQL :: MySQL Connector/Net Developer Guide :: 5.9.1 Preparing Statements in Connector/Net[
^]