How can I filter data with dates in C #?

0

In a form I have two datetimePicker, and I want to filter the data using the dates of the datetimePicker, but it does not work out. Can you tell me what I'm wrong with? I'm programming in three layer model, I leave my code.

BUSINESS LAYER (BUSSINESS):

public DataTable OEntradas(String Buscar, String FIentrada, String FFentrada)
    {
        DataTable dt = new DataTable();
        String query = "SELECT E.SKU, S.Descripcion AS Status, E.Descripcion AS Material, U.Descripcion AS Unidad, E.Cantidad, E.Costo, P.Nombre_proveedor AS Proveedor, F.Descripcion AS Familia, E.Fecha_entrada  FROM Entradas AS E inner join status AS S ON E.Status = S.id_status inner join unidadM AS U ON E.Unidad = U.id_unidad inner join proveedores AS P ON E.Proveedor = P.id_proveedor inner join familia AS F ON E.Familia = F.id_familia WHERE E.Descripcion LIKE '%"+ Buscar +"%' AND E.Fecha_entrada BETWEEN '"+ FIentrada +"' AND '"+ FFentrada +"' ";
        dt = daccess.select(query);
        return dt;
    }

CAPA DE VISTA:

private void CGrid()
    {
        DataTable de = biss.OEntradas(txt_buscar.Text, date_entrada.Text, dateTimePicker1.Text);
        data_entradas.DataSource = de;
    }

So I have my code.

    
asked by Macx 07.08.2018 в 19:17
source

1 answer

1

Why not first try to see if you return records by omitting this part of the query.

AND E.Fecha_entrada BETWEEN '"+ FIentrada +"' AND '"+ FFentrada +"' "

if it returns try to change it by

AND E.Fecha_entrada >= '"+ FIentrada +"' AND "+ " E.Fecha_entrada <= '" + FFentrada +"' "
    
answered by 07.08.2018 / 19:27
source