SqlCommand c = new SqlCommand();
c.CommandText = "SELECT id, RazonSocial, Direccion, Cp, Nif FROM Clientes "
c.CommandType = CommandType.Text;
c.Connection = conn;
switch (cbCriterio.SelectedIndex)
{
case 0:
c.CommandText += " AND UPPER(RazonSocial) = @razon";
c.Parameters.Add(new System.Data.SqlClient.SqlParameter("@razon", System.Data.SqlDbType.Variant));
c.Parameters["@razon"].Value = "%" + txtValor.Text.ToUpper()+ "%";
break;
default:
c.CommandText += " AND UPPER(Nif) = @Nif";
c.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Nif", System.Data.SqlDbType.VarChar, 9, "Nif"));
c.Parameters["@Nif"].Value = "%" + txtValor.Text.ToUpper()+ "%";
break;
}
daCli.SelectCommand = c;
dsClientes1.Clientes.Clear();
daCli.Fill(dsClientes1);
grid.DataSource = dsClientes1.Clientes;
}