Ok, grazie dell'aiuto.
1) La query provata in mysql funziona correttamente;
2) Ho aggiunto nella query un altro campo della tabella (tNome);
3) Ho eliminato dalla query il CONCAT(VariazionePercentuale,'%') As VarPerc;
3) Eliminata l'ultima riga ossia il bind al Chart1;
4) Provato con Response.Write(reader[1].ToString());
5) Ripristinata l'ultima riga ossia il bind al Chart1;
Mi stampa il valore del campo `VarPerc` -59 (corretto).
Quindi per esclusione posso dire che la sintassi CONCAT(VariazionePercentuale,'%') di mysql non è compatibile con net?
Adesso però devo utilizzare il valore del campo `VarPerc` più avanti nel codebehind e ho scritto così:
codice:
String myQuery = " SELECT tNome, " +
" VariazionePercentuale As VarPerc " +
" FROM tbl_m " +
" WHERE " +
" tNome LIKE '%Pippo%'; ";
OdbcConnection myConnectionString =
new OdbcConnection(
ConfigurationManager.ConnectionStrings["ConnMySQL"].ConnectionString);
myConnectionString.Open();
OdbcCommand objCmd = new OdbcCommand(myQuery, myConnectionString);
objCmd.Prepare();
objCmd.CommandType = CommandType.Text;
objCmd.CommandText = myQuery;
OdbcDataReader reader = objCmd.ExecuteReader();
while (reader.Read())
Response.Write(reader["VarPerc"].ToString());
reader.Close();
String top = reader["VarPerc"].ToString();
LegendItem newItem = new LegendItem();
newItem.ImageStyle = LegendImageStyle.Marker;
newItem.MarkerStyle = MarkerStyle.Diamond;
newItem.Cells.Add(LegendCellType.SeriesSymbol, "", ContentAlignment.MiddleLeft);
newItem.Cells.Add(LegendCellType.Text, "top", ContentAlignment.MiddleLeft);
newItem.Cells[1].CellSpan = 2;
newItem.Cells.Add(LegendCellType.Text, "", ContentAlignment.MiddleLeft);
newItem.Cells.Add(LegendCellType.Text, top, ContentAlignment.MiddleLeft);
Chart1.Legends[0].CustomItems.Add(newItem);
Errore:
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 692: String top = reader["VarPerc"].ToString();
Line 693: LegendItem newItem = new LegendItem();
Line 694: newItem.ImageStyle = LegendImageStyle.Marker;