Exemplo n.º 1
0
        RichTextBox txtResultsBox; // handle to the rich textbox used to display text results

        #endregion Fields

        #region Constructors

        /// <summary> Creates a MDI child form for running queries </summary>
        /// <param name="dbClient">A configured and connected dbClient object</param>
        /// <param name="browser">A database Browser object (or null if n/a)</param>
        /// <param name="hideBrowser">True if the browser should be hidden right away (low bandwidth)</param>
        public QueryForm(DbClient dbClient, IBrowser browser, bool hideBrowser)
        {
            InitializeComponent();
            this.dbClient = dbClient;
            this.browser = browser;
            lastDatabase = dbClient.Database;				// this is so we know when the current database changes
            HideResults = true;
            HideBrowser = hideBrowser || (browser == null);
            FileName = "untitled" + untitledCount++.ToString() + ".sql";
            initializing = false;
            // For some reason, the designer has trouble with 8.0 point fonts - it wants to make it
            // 7.8 or 8.25, and this looks rather naff in the statusbar.
            statusBar.Font = new Font (statusBar.Font.Name, 8, FontStyle.Bold);
        }
Exemplo n.º 2
0
        public IBrowser Clone(DbClient newDbClient)
        {
            SqlBrowser sb = new SqlBrowser(newDbClient);

            return(sb);
        }
Exemplo n.º 3
0
        private void btnConnect_Click(object sender, System.EventArgs e)
        {
            // Save contents of controls to XML file.
            // Data binding to radio buttons doesn't seem to work, sadly, so we have to do this bit manually.
            dsSettings.settings [0].SqlTrusted     = rbSqlTrusted.Checked;
            dsSettings.settings [0].OraMSDriver    = rbOraMSDriver.Checked;
            dsSettings.settings [0].ConnectionPage = tabControl.SelectedIndex;
            try { dsSettings.WriteXml(configFile); }
            catch (Exception) {}

            // Create DbClient (database client) object

            IClientFactory clientFactory;
            string         connectString, connectDescription;

            switch (tabControl.SelectedIndex)
            {
            case 0:                                                                             // SQL Server
                clientFactory = new SqlFactory();
                connectString = "Data Source=" + txtSqlServer.Text.Trim() + ";app=Query Express";
                if (rbSqlTrusted.Checked)
                {
                    connectString += ";Integrated Security=SSPI";
                }
                else
                {
                    connectString +=
                        ";User ID=" + txtSqlLoginName.Text.Trim() +
                        ";Password="******" (" +
                                     (rbSqlTrusted.Checked ? "Trusted" : txtSqlLoginName.Text.Trim()) + ")";
                break;

            case 1:                                                                             // Oracle
                // As we don't yet have Oracle .NET classes, use the OleDb family of classes instead.
                clientFactory = new OleDbFactory();
                connectString = "Provider="
                                + ((rbOraMSDriver.Checked) ? "MSDAORA" : "OraOLEDB.Oracle")
                                + ";Data Source=" + txtOraDataSource.Text.Trim()
                                + ";User ID=" + txtOraLoginName.Text.Trim() + ";Password="******"[" + connectString.Substring(0, Math.Min(25, connectString.Length)) + "...]";
                break;

            default:        return;
            }

            dbClient = new DbClient(clientFactory, connectString, connectDescription);
            Cursor oldCursor = Cursor;

            Cursor = Cursors.WaitCursor;

            ConnectingForm c = new ConnectingForm();

            c.Show();
            c.Refresh();
            bool success = dbClient.Connect();

            c.Close();
            Cursor = oldCursor;

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

            // Create a browser object (if available for the provider)

            if (tabControl.SelectedIndex == 0)                                                  // SQL Server
            {
                browser = new SqlBrowser(dbClient);
            }

            if (tabControl.SelectedIndex == 1)                                                  // Oracle
            {
                browser = new OracleBrowser(dbClient);
            }

            if (tabControl.SelectedIndex == 2)                                                  // OleDb
            {
                browser = new dl3bak.OleDbBrowser(dbClient);
            }

            DialogResult = DialogResult.OK;
        }
Exemplo n.º 4
0
        private void btnConnect_Click(object sender, System.EventArgs e)
        {
            // Save contents of controls to XML file.
            // Data binding to radio buttons doesn't seem to work, sadly, so we have to do this bit manually.
            dsSettings.settings [0].SqlTrusted = rbSqlTrusted.Checked;
            dsSettings.settings [0].OraMSDriver = rbOraMSDriver.Checked;
            dsSettings.settings [0].ConnectionPage = tabControl.SelectedIndex;
            try { dsSettings.WriteXml (configFile); }
            catch (Exception) {}

            // Create DbClient (database client) object

            IClientFactory clientFactory;
            string connectString, connectDescription;

            switch (tabControl.SelectedIndex)
            {
                case 0:								// SQL Server
                    clientFactory = new SqlFactory();
                    connectString = "Data Source=" + txtSqlServer.Text.Trim() + ";app=Query Express";
                    if (rbSqlTrusted.Checked)
                        connectString +=  ";Integrated Security=SSPI";
                    else
                        connectString +=
                            ";User ID=" + txtSqlLoginName.Text.Trim() +
                            ";Password="******" (" +
                        (rbSqlTrusted.Checked ? "Trusted" : txtSqlLoginName.Text.Trim()) + ")";
                    break;

                case 1:								// Oracle
                    // As we don't yet have Oracle .NET classes, use the OleDb family of classes instead.
                    clientFactory = new OleDbFactory();
                    connectString = "Provider="
                        + ((rbOraMSDriver.Checked) ? "MSDAORA" : "OraOLEDB.Oracle")
                        + ";Data Source=" + txtOraDataSource.Text.Trim()
                        + ";User ID=" + txtOraLoginName.Text.Trim() + ";Password="******"[" + connectString.Substring (0, Math.Min (25, connectString.Length)) + "...]";
                    break;

                default:	return;
            }

            dbClient = new DbClient (clientFactory, connectString, connectDescription);
            Cursor oldCursor = Cursor;
            Cursor = Cursors.WaitCursor;

            ConnectingForm c = new ConnectingForm();
            c.Show();
            c.Refresh();
            bool success = dbClient.Connect();
            c.Close();
            Cursor = oldCursor;

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

            // Create a browser object (if available for the provider)

            if (tabControl.SelectedIndex == 0)					// SQL Server
                browser = new SqlBrowser (dbClient);

            if (tabControl.SelectedIndex == 1)					// Oracle
                browser = new OracleBrowser (dbClient);

            if (tabControl.SelectedIndex == 2)					// OleDb
                browser = new dl3bak.OleDbBrowser (dbClient);

            DialogResult = DialogResult.OK;
        }
Exemplo n.º 5
0
        public IBrowser Clone(DbClient newDbClient)
        {
            OracleBrowser ob = new OracleBrowser(newDbClient);

            return(ob);
        }
Exemplo n.º 6
0
 public SqlBrowser(DbClient dbClient)
 {
     this.dbClient = dbClient;
 }
Exemplo n.º 7
0
 public OracleBrowser(DbClient dbClient)
 {
     this.dbClient = dbClient;
 }
Exemplo n.º 8
0
 public OracleBrowser(DbClient dbClient)
 {
     this.dbClient = dbClient;
 }
Exemplo n.º 9
0
 public IBrowser Clone(DbClient newDbClient)
 {
     SqlBrowser sb = new SqlBrowser (newDbClient);
     return sb;
 }
Exemplo n.º 10
0
 public SqlBrowser(DbClient dbClient)
 {
     this.dbClient = dbClient;
 }
Exemplo n.º 11
0
 public IBrowser Clone(DbClient newDbClient)
 {
     OracleBrowser ob = new OracleBrowser (newDbClient);
     return ob;
 }