I have this code in Visual Studio:
sqlite.Open(); //Initiate connection to the db
string stmEP = "select a.portata,a.quantita,b.QUANTITA_ATTUALE,a.COSTO_UNITARIO,a.SPESA_PORTATA from ORDINI a join QUANTITA_LIMITATE b on a.PORTATA = b.PORTATA WHERE a.CASSA = '" + MyGlobals.NOME_CASSA + "' ORDER BY a.ID,a.PORTATA;";
using var cmdEP = new SQLiteCommand(stmEP, sqlite);
using SQLiteDataReader rdrEP = cmdEP.ExecuteReader();
while (rdrEP.Read())
{
string OUT_PORTATA = (string)rdrEP["a.portata"];
Int64 OUT_QTA = (Int64)rdrEP["a.quantita"];
Int64 OUT_QTA_ATT = (Int64)rdrEP["b.QUANTITA_ATTUALE"];
MessageBox.Show(OUT_PORTATA);
}
sqlite.Close();
The error occurs on this line:
string OUT_PORTATA = (string)rdrEP["a.portata"];
Error:
System.IndexOutOfRangeException: Index was outside the bounds of the array
I don't understand why.
I'd like to extract all items in ORDINI that are also in QUANTITA_LIMITATE.