Query that generates exception ReportViewer, Visual Studio 2015, C #, MariaDB10 (SOLVED)

0

I'm with the following problem, I have an application that is responsible for generating queries through ReportViewer, the application connects to a MariaDB10 Database that handles approximately 19 million records, the data is stored by an external application that collects information of processes in a plant.
That application automatically generates its structure of tables, for the reporting system only a table is required where all the production data is stored, because that data is in a single table with only two fields to order what we use is pivot to sort the information according to the requirement of each report, one of the generated reports is throwing an exception when generating parameters parameterized by dates when selecting parameters of times of more than 20 days the report throws the exception, when reviewing the code we could see that the exception is generated just after executing the pivot query, we executed that query from the terminal directly in the database server the query took a little while to generate but in the end it did not give any error and it could generate the results.

I include the mentioned query and the line where the error is generated is "MySqlDataReader hist = histoform.ExecuteReader ();"

/*HISTORIAL FORMULA*/
string val = "", valu="";
int exitval = 0;                    
MySqlCommand histoform = new MySqlCommand("SELECT EVTTIME, SUM(DISTINCT CASE WHEN c.H_MNEMO = 'SET_CEMENTO' THEN ROUND(d.evtvalue) END) AS CEM, SUM(DISTINCT CASE WHEN c.H_MNEMO = 'SET_CARBONATO' THEN ROUND(d.evtvalue) END) AS CAR, SUM(DISTINCT CASE WHEN c.H_MNEMO = 'SK_SETCELULOSAVIRGEN' THEN ROUND(d.evtvalue) END) AS CVIR, SUM(DISTINCT CASE WHEN c.H_MNEMO = 'SK_SETCELULOSADKL' THEN ROUND(d.evtvalue) END) AS CDKL, SUM(DISTINCT CASE WHEN c.H_MNEMO = 'SK_SETPVA' THEN ROUND(d.evtvalue) END) AS PVA, SUM(DISTINCT CASE WHEN c.H_MNEMO = 'SK_SETHIDROFUGANTE' THEN ROUND(d.evtvalue) END) AS HID, SUM(DISTINCT CASE WHEN c.H_MNEMO = 'SET_LODO' THEN ROUND(d.evtvalue) END) AS LOD, SUM(DISTINCT CASE WHEN c.H_MNEMO = 'SET_FILLER' THEN ROUND(d.evtvalue) END) AS FIB, SUM(DISTINCT CASE WHEN c.H_MNEMO = 'SET_CELULOSA' THEN ROUND(d.evtvalue) END) AS DCEL, SUM(DISTINCT CASE WHEN c.H_MNEMO = 'SK_SETFORMULAOTROS' THEN ROUND(d.evtvalue) END) AS OTR, SUM(DISTINCT CASE WHEN c.H_MNEMO = 'SK_VALCODIGOFORMULMATPRIM' THEN ROUND(d.evtvalue) END) AS FORM FROM DATOSDT D,configuration c WHERE c.evtcellule = d.evtcellule AND EVTTIME BETWEEN '" + fecinic + "' AND '" + fecfinc + "' GROUP BY d.EVTTIME HAVING FORM IS NOT NULL ORDER BY d.EVTTIME DESC;", con.conected());
MySqlDataReader hist = histoform.ExecuteReader();
                    if (hist.HasRows)
                    {
                        while (hist.Read())
                        {
                            if (hist[1].ToString() != "" && hist[2].ToString() != "" && hist[3].ToString() != "" && hist[4].ToString() != "" && hist[5].ToString() != "" && hist[6].ToString() != "" && hist[7].ToString() != "" && hist[8].ToString() != "" && hist[9].ToString() != "" && hist[10].ToString() != "" && hist[11].ToString() != "")
                            {
                                if (hist[11].ToString() != "")
                                {
                                    if (hist[11].ToString() != val)
                                    {
                                        filas = dt.FORMULAHIST.NewRow();
                                        filas["FECHA"] = hist[0].ToString();
                                        filas["CEMENTO"] = hist[1].ToString();
                                        filas["CARBONATO"] = hist[2].ToString();
                                        filas["CELVIRGEN"] = hist[3].ToString();
                                        filas["CELDKL"] = hist[4].ToString();
                                        filas["PVA"] = hist[5].ToString();
                                        filas["HIDRO"] = hist[6].ToString();
                                        filas["LODO"] = hist[7].ToString();
                                        filas["FIBER"] = hist[8].ToString();
                                        filas["DESCCEL"] = hist[9].ToString();
                                        filas["OTRO"] = hist[10].ToString();
                                        filas["CODIGO"] = hist[11].ToString();
                                        dt.FORMULAHIST.Rows.Add(filas);
                                        exitval++;
                                    }
                                    val = hist[11].ToString();
                                }
                            }
                        }
                        con.CerrarConexion();
                    }
    
asked by root2 22.06.2018 в 16:53
source

1 answer

2

Hi, I was able to solve my problem, it was on the msdn forums, anyway I publish this solution in this post in case someone else can help you thanks for the answers.

  

Matiza what "the query takes a little in generating." How much is it   "a little"? If it's more than 30 seconds, almost certainly the problem is   that the MySqlCommand generated a TimeOut. You can change the value   default of 30 seconds using the CommandTimeOut property.

     

histoform.CommandTimeOut = 120;

     

In either case, it looks like an internal ADO.NET problem, or   the database drivers, or the query itself. I do not think that the   ReportViewer has nothing to do with the matter.

Proposed as answer by Juan MondragónModerator Monday, June 25, 2018 6:59 PM
    
answered by 04.07.2018 в 15:27