示例#1
0
        private static DatabaseSchema GetDatabaseSchema(DbConnection connection)
        {
            var dbReader = new DatabaseReader(connection);

            dbReader.AllSchemas();
            return(dbReader.ReadAll());
        }
示例#2
0
        public void DiscoverDb2Schemas()
        {
            const string providername     = "IBM.Data.DB2";
            const string connectionString = @"Server=localhost:50000;UID=db2admin;pwd=db2;Database=Sample";

            ProviderChecker.Check(providername, connectionString);

            var dbReader = new DatabaseReader(connectionString, providername);
            var schemas  = dbReader.AllSchemas();

            Assert.IsTrue(schemas.Count > 0);
        }
示例#3
0
        public void MySqlSchemasTest()
        {
            const string providername     = "MySql.Data.MySqlClient";
            var          connectionString = ConnectionStrings.MySql;

            ProviderChecker.Check(providername, connectionString);

            var dbReader = new DatabaseReader(connectionString, providername);

            dbReader.Owner = "sakila";
            var schemas = dbReader.AllSchemas();

            Assert.IsTrue(schemas.Count > 0, "Schemas should contain sakila");
        }
示例#4
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            if (isProcessRunning)
            {
                return;
            }

            IList <DatabaseDbSchema> schemas = new List <DatabaseDbSchema>();

            string  connectionStr = connectionStringTextBox.Text.Trim();
            SqlType serverType    = (SqlType)serverTypeComboBox.SelectedItem;

            // Initialize the dialog that will contain the progress bar
            ProgressDialog progressDialog = new ProgressDialog();

            // Set the dialog to operate in indeterminate mode
            progressDialog.SetIndeterminate(true);

            // Initialize the thread that will handle the background process
            Thread backgroundThread = new Thread(
                new ThreadStart(() =>
            {
                try
                {
                    isProcessRunning = true;

                    //Create the database reader object.
                    var metadataReader = new DatabaseReader(connectionStr, serverType);
                    schemas            = metadataReader.AllSchemas();

                    if (cboSchema.InvokeRequired)
                    {
                        cboSchema.BeginInvoke(new Action(() =>
                        {
                            cboSchema.DataSource = schemas.Select(x => x.Name).ToList();
                        }));
                    }

                    Thread.Sleep(500);
                }
                catch (Exception ex)
                {
                    Invoke(new MethodInvoker(() =>
                    {
                        MessageBox.Show(
                            this,
                            ex.Message,
                            Translations.Strings.Error,
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
                    }));
                }
                finally
                {
                    isProcessRunning = false;

                    if (progressDialog.InvokeRequired)
                    {
                        progressDialog.BeginInvoke(new Action(() => progressDialog.Close()));
                    }
                }
            }));

            // Sets to single thread apartment (STA) mode before OLE calls
            backgroundThread.SetApartmentState(ApartmentState.STA);

            // Start the background process thread
            backgroundThread.Start();

            // Open the dialog
            progressDialog.ShowDialog();
        }