Date notice in the app

Asked

Viewed 85 times

0

I’m developing a C# application in Visual Studio. In this application there is a screen that informs the amount of events that the user has today, tomorrow and the day after tomorrow (table with green header).

Follow the screen:

Software

I need a code that compares the current date with the date registered in the database about the event and send the number of events registered for the future days.

Ex.: No day 05/08/2016 a user registered an event for today (08/08/2016) and this event was analyzed by the code and the sum of today’s events (08/08/2016) It was sent to the label.Text and so on.

In short, the code should analyze the events for three days and send the sum of events for three label.Text, current day, day after and day after the day after.

The code I refer to at the bank:

public DataTable Load(string sql)
{
    DALTexto objSqlCeServerDAL = DALTexto.GetInstance(connString); 
    objSqlCeServerDAL.Open();
    SqlCeDataAdapter dAd = new SqlCeDataAdapter(sql, objSqlCeConnection);
    dAd.SelectCommand.CommandType = CommandType.Text;
    DataSet dSet = new DataSet();
    try
    {
        dAd.Fill(dSet, "textos");
        return dSet.Tables["textos"];
    }
    catch
    {
        throw;
    }
    finally
    {
        dSet.Dispose();
        dAd.Dispose();
        objSqlCeServerDAL.Dispose();
    }
}
  • 3

    What have you tried ?

  • @stringnome I tried the Datatable method, but missed some part if I am not mistaken, so I did not succeed.

  • 1

    Try to be more specific. How is the database query done? Do you use any ORM? Have you tried anything? Little worth the image you posted, try [Edit] your question and improve it a little, add your attempts and relevant information...

  • @jbueno I added details

  • Marlon, try using instead of datatable, something like Dictionary, or better a List, because they are highly typed objects, and you can access them directly with an index, to access a datatable data you will need to use a Datareader.

  • Can you give me an example?

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.