Esempio n. 1
0
        /// <summary>
        /// Runs the queries and generate a list of datatable
        /// </summary>
        private List<DataTable> RunQueries()
        {
            List<DataTable> listResults = new List<DataTable>();

            try
            {
                RunQuery runQuery = new RunQuery();

                // returns if the build failed
                if (!_isReadToRun) return new List<DataTable>();

                // returns if not connection is available
                if (_connList.Count == 0) return new List<DataTable>();

                for (int i = 0; i < _sqlList.Count; i++)
                {

                        string query = _sqlList[i];
                        string conn = _sqlList.Count == _connList.Count
                            ? _connList[i]
                            : _connList[0];

                        // adds the results to a list so that it can be process in the next step, the try catch to empty space is because we dont want the execution to stop because some type of error
                    try
                    {
                        listResults.Add(runQuery.GetData(conn, query));
                    }
                    catch (Exception ex)
                    {
                        if (_queryDebug)
                            throw new Exception("error running query at position " + i + " - " + ex.Message);
                    }
                }

            }
            catch (Exception ex)
            {
                throw new Exception("error running queries " + ex.Message);
            }

            return listResults;
        }
Esempio n. 2
0
        /* PRIVATE */
        /// <summary>
        /// Run Query and return a datatable
        /// </summary>
        private DataTable GetData(string conn, string sql)
        {
            try
            {
                RunQuery runQuery = new RunQuery();

                DataTable dt = runQuery.GetData(conn, sql);

                _dataRetrievedWithSuccess = true;

                return dt;
            }
            catch (Exception ex)
            {
                ErrorMsg = ex.Message;

                return new DataTable();
            }
        }