Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool TryingtoStart = true;
- while (TryingtoSTart)
- {
- try
- {
- dbc.Open();
- departmentDataAdapter = new SQLiteDataAdapter("select * from DEPARTMENT", dbc);
- // etc
- }
- catch (SQLiteException ex)
- {
- DialogResult r = MetroFramework.MetroMessageBox.Show(this, ex.Message.ToString(), "Database error", MessageBoxButtons.RetryCancel);
- if (r == DialogResult.Cancel) TryingtoStart = false;
- }
- catch (Exception exc)
- {
- DialogResult r = MetroFramework.MetroMessageBox.Show(this, exc.Message.ToString(), "Exception", MessageBoxButtons.RetryCancel);
- if (r == DialogResult.Cancel) TryingtoStart = false;
- }
- if (!TryingtoStart) Application.Exit();
- }
- "Operation is not valid due to the current state of the object."
- System.InvalidOperationException: Operation is not valid due to the current state of the object.
- at System.Data.SQLite.SQLiteConnection.Open()
- bool TryingtoStart = true;
- while (TryingtoSTart)
- {
- using(var dbc = new SQLiteConnection(connectionString))
- {
- try
- {
- using(var departmentDataAdapter = new SQLiteDataAdapter("select * from DEPARTMENT", dbc))
- {
- // etc
- }
- // Note: This row will only be executed if there where no exceptions until this point in the code
- TryingtoStart = false;
- }
- catch (SQLiteException ex)
- {
- if (MetroFramework.MetroMessageBox.Show(this, ex.Message.ToString(), "Database error", MessageBoxButtons.RetryCancel) == DialogResult.Cancel) Application.Exit();
- }
- catch (Exception exc)
- {
- if (MetroFramework.MetroMessageBox.Show(this, exc.Message.ToString(), "Exception", MessageBoxButtons.RetryCancel) == DialogResult.Cancel) Application.Exit();
- }
- }
- }
Add Comment
Please, Sign In to add comment