This is an excerpt from my code. Everything works the way it's supposed to, but I'm trying to add a feature which allows the program to return more than one row from the database - that is to say, more than one result.
If I search for "silver", I get Silverado; if I search "silver l", I get Silver Linings Playbook.
What I've been trying to get it to do is to search for "silver" and get Silverado AND Silver Linings Playbook, but my loops haven't fixed the issue and some help would be...helpful.
movieBox.Items.Clear();
try
{
db_connection.Open();
sql_command = new MySqlCommand("select * from mov_db.movies where title like '%" + searchBox.Text + "%'", db_connection);
sql_reader = sql_command.ExecuteReader();
if (sql_reader.Read())
{
movieBox.Items.Add(sql_reader.GetString("title"));
movieBox.Items.Add(sql_reader.GetString("year"));
movieBox.Items.Add(sql_reader.GetString("genre"));
movieBox.Items.Add(sql_reader.GetString("rating"));
}
else
{
MessageBox.Show("Sorry, but that title is unavailable.");
}
}
Aucun commentaire:
Enregistrer un commentaire