Click here to Skip to main content
16,004,761 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
C#
OleDbConnection connection = MSAConnection.getConnection();
OleDbDataAdapter adapter = new OleDbDataAdapter();

string query = @"SELECT * FROM Persona
            WHERE NOT EXISTS
            (SELECT * FROM MarcacionesAsistencia
            WHERE (MarcacionesAsistencia.codPersona = Persona.codPersona)

            AND (MarcacionesAsistencia.tipoPersona = @tipo ))
            AND(MarcacionesAsistencia.fecha >= @desde)
            AND(MarcacionesAsistencia.fecha <= @hasta);";

OleDbCommand command = new OleDbCommand(query, connection);

command.Parameters.AddWithValue("@tipo", "Docente");
command.Parameters.AddWithValue("@desde", dateTimePickerDesde.Value);
command.Parameters.AddWithValue("@hasta", dateTimePickerHasta.Value);

adapter.SelectCommand = command;

DataSetReporteFalta falta = new DataSetReporteFalta();
falta.Clear();

adapter.Fill(falta, "DTReporteFalta");
dataGridView1.DataSource = falta;
dataGridView1.DataMember = "DTReporteFalta";


What I have tried:

C#
AND (MarcacionesAsistencia.tipoPersona Like @tipo ))
AND(MarcacionesAsistencia.fecha >= @desde)
AND(MarcacionesAsistencia.fecha <= @hasta);";
Posted
Updated 22-Aug-17 6:13am
Comments
j snooze 25-Jul-17 17:33pm    
what is happening that you are not getting what you want? All I see is you describing what you want to do. No issues, errors or problems have been stated.
Rodrigo Alex Rodriguez 26-Jul-17 10:17am    
I have a school, as the students arrive, teachers and principal register (with the code, name, date).
The problem is that I can not find a way to generate a report of the students, teachers who did not arrive using a date range.
Rodrigo Alex Rodriguez 26-Jul-17 10:20am    
to the query does not throw any data

hi try this
selct * from person(select * from person where person=@person and access=@access and date betweeen from and to)
 
Share this answer
 
Comments
Rodrigo Alex Rodriguez 22-Aug-17 12:10pm    
Completely restructure my method.
The solution to my query is
"select p.codPersona, p.tipoPersona, p.nombreCompleto, p.grado, p.paralelo from Persona p where not exists(select ma.codPersona from MarcacionesAsistencia ma where ma.codPersona = p.codPersona and ma.fecha = # " + dateString + " #)"
This is my solution
I hope you help them



private void getFaltas()
        {


            string dateString = dateTimePickerFalta.Value.ToString("yyyy/MM/dd");

            adapter.SelectCommand = new OleDbCommand
                    ("select p.codPersona, p.tipoPersona, p.nombreCompleto, p.grado, p.paralelo from Persona p where not exists(select ma.codPersona from MarcacionesAsistencia ma where ma.codPersona = p.codPersona and ma.fecha = # " + dateString + " #)", connection);

            dataset.Clear();

            adapter.Fill(dataset, "DTFaltas");
            dataGridView1.DataSource = dataset;
            dataGridView1.DataMember = "DTFaltas";
            dataGridView1.Refresh();

            reportViewerFaltas.Clear();
            reportViewerFaltas.RefreshReport();

        }
 
Share this answer
 
Comments

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900