Hello everyone
I have a problem using a "search" statement in mysql, using c#, here is my code:
private void btnBuscar_Click(object sender, EventArgs e)
{
SearchBook(txtBuscar.Text);
}
private void SearchBook(string bookID)
{
String connStr = "Server=localhost; Port=3306; Database=biblioteca;Uid=root;Pwd= -----;";
DataTable dt = new DataTable();
const string query = "SELECT FROM libros WHERE l_LibroID = @l_LibroID";
using (MySqlConnection conn = new MySqlConnection(connStr))
{
conn.Open();
using (MySqlCommand cmd = new MySqlCommand(query, conn))
{
cmd.Parameters.Add(new MySqlParameter("@l_LibroID", MySqlDbType.VarChar)).Value = bookID;
cmd.ExecuteNonQuery();
dt.Load(cmd.ExecuteReader());
dgvResultadosBusqueda.DataSource = dt;
}
}
}
My problem here is that I want to display some data into a datagridview but I have an exception, so, if you can help me to find what I'm a doing wrong, I would appreciate it :),
Thanks in advance