示例#1
0
        private void cmdConnect_Click(object sender, EventArgs e)
        {
//            if (cboSqlServer.SelectedItem == null)
//                conSettings = new ConnectionSettings();
            ScreenToSettings();

            if (!DbClientFactory.ValidateSettings(conSettings))
            {
                return;
            }
            client = DbClientFactory.GetDBClient(conSettings);
            Cursor oldCursor = Cursor;

            Cursor = Cursors.WaitCursor;

            ConnectingForm c = new ConnectingForm();

            c.Show(this);
            c.Refresh();

            bool success = client.Connect();

            c.Close();
            Cursor = oldCursor;

            if (!success)
            {
                MessageBox.Show("Unable to connect: " + client.ErrorMessage, "Query Express", MessageBoxButtons.OK, MessageBoxIcon.Error);
                client.Dispose();
                return;
            }

            DialogResult = DialogResult.OK;
        }
示例#2
0
        private IQueryForm DoConnect(ConnectionSettings conSettings)
        {
            DbClient client    = DbClientFactory.GetDBClient(conSettings);
            Cursor   oldCursor = Cursor;

            Cursor = Cursors.WaitCursor;

            ConnectingForm c = new ConnectingForm();

            c.Show();
            c.Refresh();

            bool success = client.Connect();

            c.Close();
            Cursor = oldCursor;

            if (!success)
            {
                MessageBox.Show("Unable to connect: " + client.ErrorMessage, "Query Express", MessageBoxButtons.OK, MessageBoxIcon.Error);
                client.Dispose();
                return(null);
            }
            int settingIndex = serverList.IndexOf(client.ConSettings.Key);

            if (settingIndex >= 0)
            {
                serverList.Items[settingIndex] = (client.ConSettings);
            }
            else
            {
                serverList.Add(client.ConSettings);
            }
            SaveServerList();
            QueryForm qf = new QueryForm(client, false); //, cf.Browser, cf.LowBandwidth);

            qf.MdiParent   = this;
            qf.WindowState = FormWindowState.Maximized;
            // This is so that we can update the toolbar and menu as the state of the QueryForm changes.
            qf.PropertyChanged += new EventHandler <EventArgs>(qf_PropertyChanged);
            qf.MRUFileAdded    += new EventHandler <MRUFileAddedEventArgs>(qf_MRUFileAdded);
            qf.Show();

            return(qf);
        }