Heloo,
I have created 4 arays, 2 for a first select from database:
Program.Connection.CommandText = "SELECT ......................";
Program.Connection.AddParameter("@dataInceput", PrimaZiDinLuna);
Program.Connection.AddParameter("@dataSfarsit", UltimaDataDinLuna);
DataTable TableNirProduse = new DataTable();
Program.Connection.FillDataTable(TableNirProduse, true);
decimal[] SoldIntrari = new decimal[TableNirProduse.Rows.Count];
int[] CatProdusNr = new int[TableNirProduse.Rows.Count];
for (int j = 0; j < TableNirProduse.Rows.Count; ++j)
{
SoldIntrari[j] = Convert.ToDecimal(TableNirProduse.Rows[j]["PretPropusVanzare"].ToString());
CatProdusNr[j] = Convert.ToInt32(TableNirProduse.Rows[j]["CatProdus"].ToString());
}
and another 2 array for a selet select:
Program.Connection.CommandText = "SELECT ................";
Program.Connection.AddParameter("@dataInceput", PrimaZiDinLuna);
Program.Connection.AddParameter("@dataSfarsit", UltimaDataDinLuna);
DataTable TableNirProduseVandute = new DataTable();
Program.Connection.FillDataTable(TableNirProduseVandute, true);
decimal[] SoldProduseVandute = new decimal[TableNirProduseVandute.Rows.Count];
int[] CatProdusNrVandut = new int[TableNirProduseVandute.Rows.Count];
for (int i = 0; i < TableNirProduseVandute.Rows.Count; ++i)
{
SoldProduseVandute[i] = Convert.ToDecimal(TableNirProduseVandute.Rows[i]["PretVanzare"].ToString());
CatProdusNrVandut[i] = Convert.ToInt32(TableNirProduseVandute.Rows[i]["CatProdus"].ToString());
}
Both query select group record by CatProdusNr, and CatProdusNrVandut and make SUM(), for each group.
I need to save in my database the sum for each category from the first query, and ADD (+) the sum from second query to the category they correspond.
Now a what to save the result from twos 2 select back to database, i don't now how to check the equality from those arrays:
For example:
if CatProdusNr[j] == CatProdusNrVandut[i] - save to database.
Atother problem is that the first select has a number of record, and second select is possible to be different in number of records.
For example:
I have in my database (first query select) - 4 record (CatProdusNr[4] = {5,6,10,11} )
and in second query - 1 record (CatProdusNrVandut[1] = {5})
or vice-versa.
How doo i save in database those values.