Riesumo questo post per l'ennesimo problema...
Bene devo fare due stringhe dati e datig con 2 diverse query e ho fatto in questo modo:
codice:
string str_conn.......
OleDbConnection cnn = new OleDbConnection(str_conn) ;
// dati dettagliati
OleDbCommand cmd = new OleDbCommand ("SELECT * FROM " + tableName + " ORDER BY " + ordine + " ASC", cnn);
cnn.Open();
OleDbDataReader dr=cmd.ExecuteReader();
string dati=string.Empty;
while (dr.Read())
{
dati=string.Format("{0}{1} - {2}
",dati,
dr["nome"].ToString(),dr["data"].ToString());
}
cnn.Close();
// dati generici
OleDbCommand cmd2 = new OleDbCommand ("SELECT Nome, Count(*)AS Conteggio FROM stat GROUP BY " + ordine + " ORDER BY " + ordine + " ASC", cnn);
cnn.Open();
OleDbDataReader dr2=cmd.ExecuteReader();
string datig=string.Empty;
while (dr2.Read())
{
datig=string.Format("{0}{1} - {2}
",dati,
dr["nome"].ToString(),dr["conteggio"].ToString());
}
cnn.Close();
Partendo dal presupposto che la seconda query è per forza esatta in quanto l'ho copiata da una pagina dove funziona. Essendo che come errore mi viene restituito un "colonna o riga vuota" direi che ho sbagliato qualcosa nel duplicare la seconda concatenazione, ma ovviamente non so dove...
No data exists for the row/column.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: No data exists for the row/column.
Source Error:
Line 88: while (dr2.Read())
Line 89: {
Line 90: datig=string.Format("{0}{1} - {2}
",dati,
Line 91: dr["nome"].ToString(),dr["conteggio"].ToString());
Line 92: }
(errore su linea 90)