Im trying to select a row in mysql database using a textbox's text. However when I use the following code I get an error.
MySqlCommand command = connection.CreateCommand(); //we create a command
command.CommandText = "SELECT * FROM info where id=" + textBox1.Text ; //in commandtext, we write the Query
MySqlDataReader reader = command.ExecuteReader(); //execute the SELECT command, which returns the data into the reader
while (reader.Read()) //while there is data to read
{
MessageBox.Show(reader["info"].ToString());
}
It works fine with letters but when I try to use a question mark or anything like that i get the following error:
"Parameter '?' must be defined."
parameters as given in the answers below.