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:
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();
}
}
What have you tried ?
– stringnome
@stringnome I tried the Datatable method, but missed some part if I am not mistaken, so I did not succeed.
– Marlon Pereira
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...
– Jéf Bueno
@jbueno I added details
– Marlon Pereira
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.
– Thomas Erich Pimentel
Can you give me an example?
– Marlon Pereira