I have this sentence in c # to perform a parameterized or filtered search using the like.
else if(rbnombre.Checked==true)
{
try
{
if (txtbusqueda.Text == "")
{
MessageBox.Show("Debe de llenar el campo de filtro para realizar la busqueda", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning);
txtbusqueda.Focus();
}
else
{
con.Open();
SqlCommand consulta = new SqlCommand("SELECT * FROM Usuarios NOMBRE LIKE '%" + txtbusqueda.Text + "%'", con);
SqlDataAdapter da = new SqlDataAdapter(consulta);
DataTable dt = new DataTable();
da.Fill(dt);
dtgv.DataSource = dt;
}
}
catch (Exception ex)
{
MessageBox.Show("La consulta no arrojo resultados" + ex, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
con.Close();
}
I get this error: incorrect syntax near of keyword 'like'