I have this section of my code to search all the records that I need between the dates 1-28 of each month only that at the time of executing it shows information that does not exist, in this case I do not have records after May and the reader follows working until December copying what had in this case exemplified it looks like this:
Abril 100
Mayo 200
Junio 200
Julio 200
Agosto 200
and continues writing 200 until December, finally I do not know where my error is, I hope someone gives me an advice or point of view
private void fillGraph() {
OleDbConnection connection = new OleDbConnection();
connection.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=DB\DB.mdb";
int mesC = 0;
List<decimal> Anual = new List<decimal>();
for (int i = 0; i <= 11; i++)
{
mesC = i;
connection.Open();
string sQue = "Select * from [Cuentas pagadas] where [Dia pago] between #1/" + Convert.ToString(mesC + 1) + "/2016# AND #28/" + Convert.ToString(mesC + 1) + "/2016# AND [Concepto]='" + cActual + "' ";
OleDbCommand cmd = new OleDbCommand(sQue, connection);
OleDbDataReader reader = cmd.ExecuteReader();
List<decimal> sumaMes = new List<decimal>();
sumaMes.Clear();
string t = "";
while (reader.Read())
{
t = reader["Monto Pagado"].ToString();
sumaMes.Add(Convert.ToDecimal(t));
}
if (sumaMes.Count > 0)
{
decimal Total = 0;
for (int e = 0; e <= sumaMes.Count - 1; e++)
{
Total += sumaMes[e];
}
Anual.Add(Total);
connection.Close();
}
else {
Anual.Add(0);
connection.Close();
}
}
connection.Close();
DateTimeFormatInfo mes = new DateTimeFormatInfo();
int mesG = 0;
for (int i = 0; i <= 11; i++)
{
mesG = i;
chBalance.Series["Fruc"].Points.AddXY(mes.GetMonthName(mesG + 1),Anual[i]);
}
}