BF2Statistics.ExceptionForm.ShowDbConnectError C# (CSharp) Method

ShowDbConnectError() public static method

Displays a custom version of this form to display database connection errors
public static ShowDbConnectError ( DbConnectException e ) : void
e DbConnectException
return void
        public static void ShowDbConnectError(DbConnectException e)
        {
            using (ExceptionForm F = new ExceptionForm(e, true))
            {
                F.WindowTitle = "Database Connect Error";
                F.HeaderText = "Database Connect Error";
                F.Message = "Unable to establish a connection to the database.";
                F.ImgIcon = Properties.Resources.vistaWarning;
                F.ShowDialog();
            }
        }

Usage Example

        /// <summary>
        /// Reset Unlocks Button Click Event
        /// </summary>
        private void ResetUnlocksBtn_Click(object sender, EventArgs e)
        {
            try
            {
                // Create New Player Unlock Data
                StringBuilder Query = new StringBuilder("INSERT INTO unlocks VALUES ");

                // Normal unlocks
                for (int i = 11; i < 100; i += 11)
                {
                    Query.AppendFormat("({0}, {1}, 'n'), ", Pid, i);
                }

                // Sf Unlocks
                for (int i = 111; i < 556; i += 111)
                {
                    Query.AppendFormat("({0}, {1}, 'n')", Pid, i);
                    if (i != 555)
                    {
                        Query.Append(", ");
                    }
                }

                // Do driver queries
                using (StatsDatabase Driver = new StatsDatabase())
                    using (DbTransaction T = Driver.BeginTransaction())
                    {
                        try
                        {
                            // Perform queries
                            Driver.Execute("DELETE FROM unlocks WHERE id = " + Pid);
                            Driver.Execute("UPDATE player SET usedunlocks = 0 WHERE id = " + Pid);
                            Driver.Execute(Query.ToString());
                            T.Commit();

                            // Notify user
                            Notify.Show("Player Unlocks Have Been Reset", "This player will be able to select his new unlocks upon logging in.", AlertType.Success);
                        }
                        catch
                        {
                            T.Rollback();
                            throw;
                        }
                    }
            }
            catch (DbConnectException Ex)
            {
                HttpServer.Stop();
                ExceptionForm.ShowDbConnectError(Ex);
                this.Close();
            }
        }
All Usage Examples Of BF2Statistics.ExceptionForm::ShowDbConnectError