/// <summary> /// Runs the SQL. /// </summary> /// <param name="sqlCommand">The SQL command.</param> /// <param name="sqlParams">The SQL parameters.</param> /// <param name="storedProcedure">if set to <c>true</c> [stored procedure].</param> /// <param name="statusText">The status text.</param> public void RunSQL(string sqlCommand, List <SqlParameter> sqlParams, bool storedProcedure, out string statusText) { statusText = string.Empty; try { // remove any existing commands Session.RemoveAll(); if (_trigger != null) { _trigger.Dispose(); } // create command and assign delegate handlers _trigger = new LogTrigger(); _trigger.LogEvent += new LogTrigger.InfoMessage(LogEvent); _trigger.connection = new SqlConnection(TableExtensions.GetConnectionString()); _trigger.command = new SqlCommand(sqlCommand); if (storedProcedure) { _trigger.command.CommandType = CommandType.StoredProcedure; } foreach (var param in sqlParams) { _trigger.command.Parameters.Add(param); } // start the command and the timer _trigger.Start(); tmrSyncSQL.Enabled = true; Session["trigger"] = _trigger; } catch (Exception ex) { statusText += string.Format("Could not connect to the database. {0}<br>", ex.Message); } }