Ejemplo n.º 1
0
        public void NewDatabase()
        {
            DbProvider provider = SelectProvider();

            if (provider == null)
            {
                return;
            }
            if (!provider.IsFileBased)
            {
                MessageBox.Show(this, "Selected Database is not File based, No creation supported.", "Information");
                return;
            }

            if (saveFileDialog.ShowDialog(this) == DialogResult.OK)
            {
                string fileName = saveFileDialog.FileName;
                try {
                    string connectionString = provider.CreateDatabaseFile(fileName);
                    using (ConnectionStringForm box = new ConnectionStringForm()) {
                        box.ConnectionStringBuilder = provider.CreateConnectionStringBuilder();
                        box.ConnectionStringBuilder.ConnectionString = connectionString;
                        if (box.ShowDialog(this) == DialogResult.OK)
                        {
                            Database db = provider.CreateDatabase(box.DatabaseName, box.ConnectionString);
                            AddNewDatabase(db);
                        }
                    }
                } catch (Exception ex) {
                    MessageBox.Show(this, ex.Message, "Error on creating database");
                }
            }
        }
Ejemplo n.º 2
0
        public void OpenDatabase()
        {
            DbProvider provider = SelectProvider();

            if (provider == null)
            {
                return;
            }

            using (ConnectionStringForm box = new ConnectionStringForm()) {
                box.ConnectionStringBuilder = provider.CreateConnectionStringBuilder();
                if (box.ShowDialog(this) == DialogResult.OK)
                {
                    Database db = provider.CreateDatabase(box.DatabaseName, box.ConnectionString);
                    AddNewDatabase(db);
                }
            }
        }
Ejemplo n.º 3
0
 private void modifyConnectionToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (Disconnect(SelectedDatabaseNode))
     {
         using (ConnectionStringForm box = new ConnectionStringForm()) {
             Database db = this.SelectedDatabase;
             box.DatabaseName            = db.Name;
             box.IsUpdate                = true;
             box.ConnectionStringBuilder = db.Provider.CreateConnectionStringBuilder();
             box.ConnectionStringBuilder.ConnectionString = db.ConnectionString;
             if (box.ShowDialog(this) == DialogResult.OK)
             {
                 db.ChangeConnectionString(box.ConnectionString);
                 DatabasesManager.IsCollectionDirty = true;
                 ShowNodeProperties(treeView.SelectedNode);
             }
         }
     }
 }