Example #1
0
        /// <summary>
        /// Execute an Explain or Explain Query Plan on the SQL Statement and show the results.
        /// </summary>
        /// <param name="ExplainPlan">true- Execute 'Explain', false - Execute 'Explain Query Plan'</param>
        internal void Explain(bool ExplainPlan)
        {
            string sql = GetSQL();

            if (string.IsNullOrEmpty(sql))
            {
                return;
            }

            toolStripResult.Text   = string.Empty;
            toolStripRowCount.Text = string.Empty;
            toolStripClock.Text    = string.Empty;

            Int64 startclock = Timers.QueryPerformanceCounter();

            sql = ExplainPlan ? string.Format("Explain {0}", sql) : string.Format("Explain Query Plan {0}", sql);
            DataTable dt = DataAccess.ExecuteDataTable(DatabaseName, sql, out SQLiteErrorCode returnCode);

            if (returnCode == SQLiteErrorCode.Ok)
            {
                gvResults.DataSource = dt;
                gvResults.Refresh();
                gvResults.Visible     = true;
                txtSqlResults.Visible = false;
                toolStripResult.Text  = Common.OK_EXPLAIN;
            }
            else
            {
                gvResults.Visible     = false;
                txtSqlResults.Visible = true;
                txtSqlResults.Text    = string.Format(Common.ERR_EXPLAIN, DataAccess.LastError, returnCode.ToString());
                toolStripResult.Text  = Common.ERR_EXPLAINERR;
            }
            toolStripClock.Text = Timers.DisplayTime(Timers.QueryLapsedTime(startclock));
            return;
        }
Example #2
0
 internal void ProgressEventHandler(object sender, ProgressEventArgs e)
 {
     e.ReturnCode        = CancelExecution ? SQLiteProgressReturnCode.Interrupt : SQLiteProgressReturnCode.Continue;
     toolStripClock.Text = Timers.DisplayTime(Timers.QueryLapsedTime(startclock));
     Application.DoEvents();
 }