private void wizardPageOLASelEvent_ShowFromNext(object sender, EventArgs e) { EventSoftwareOLA ola = GetOlaEventSoftware(); IDbConnection conn = ola.GetDBConnection(); try { conn.Open(); IDbCommand cmd = conn.CreateCommand(); cmbOlaEvent.Items.Clear(); cmd.CommandText = "SELECT VersionNumber FROM Version WHERE moduleId = 1"; try { object res = cmd.ExecuteScalar(); } catch (Exception ee) { if (ee.Message.ToUpper().Contains("ENOUGH RIGHTS")) { conn.Close(); conn = new H2Connection("jdbc:h2://" + txtOlaDBLoc.Text.Replace(".h2.db", "") + ";AUTO_SERVER=TRUE", "root", ""); try { conn.Open(); cmd = conn.CreateCommand(); TryApplyReadRights(cmd); } finally { conn.Close(); } conn = ola.GetDBConnection(); conn.Open(); cmd = conn.CreateCommand(); } } cmd.CommandText = "select eventid, name from Events"; IDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { OlaComp cmp = new OlaComp(); cmp.Id = Convert.ToInt32(reader["eventid"].ToString()); cmp.Name = Convert.ToString(reader["name"]); cmbOlaEvent.Items.Add(cmp); } reader.Close(); cmd.Dispose(); if (cmbOlaEvent.Items.Count > 0) cmbOlaEvent.SelectedIndex = 0; } finally { conn.Close(); } }
private void wizardPage3_ShowFromNext(object sender, EventArgs e) { StoreSettings(); /*Try Connect*/ IDbConnection conn = null; try { if (comboBox1.SelectedIndex == 0 && !System.IO.File.Exists(txtOlaDb.Text.Replace(".h2.", ".lock."))) { MessageBox.Show("OLA Does not seem to be started on server?\r\nPlease make sure OLA is running with connected clients when connecting, else all traffic will be redirected through this computer!"); } conn = GetDBConnection(lstDB.SelectedItem as string); conn.Open(); IDbCommand cmd = conn.CreateCommand(); cmbOLAComp.Items.Clear(); cmd.CommandText = "SELECT VersionNumber FROM Version WHERE moduleId = 1"; try { object res = cmd.ExecuteScalar(); } catch (Exception ee) { if (ee.Message.ToUpper().Contains("ENOUGH RIGHTS")) { conn.Close(); conn = new H2Connection("jdbc:h2://" + txtOlaDb.Text.Replace(".h2.db", "") + ";AUTO_SERVER=TRUE", "root", ""); try { conn.Open(); cmd = conn.CreateCommand(); TryApplyReadRights(cmd); } finally { conn.Close(); } conn = GetDBConnection(lstDB.SelectedItem as string); conn.Open(); cmd = conn.CreateCommand(); } } cmd.CommandText = "select eventid, name from Events"; IDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { OlaComp cmp = new OlaComp(); cmp.Id = Convert.ToInt32(reader["eventid"].ToString()); cmp.Name = Convert.ToString(reader["name"]); cmbOLAComp.Items.Add(cmp); } reader.Close(); cmd.Dispose(); if (cmbOLAComp.Items.Count > 0) cmbOLAComp.SelectedIndex = 0; } catch (Exception ee) { MessageBox.Show(this, ee.Message); } finally { if (conn != null) conn.Close(); } }