private void btnQuery_Click(object sender, EventArgs e) { if (cbConnectionStrings.SelectedItem == null) { return; } string cnName = cbConnectionStrings.SelectedItem.ToString(); DbSchema schema = DbSchemaFactory.Create(cnName); string schemaName = cbSchemaName.SelectedItem == null ? cbSchemaName.Text : cbSchemaName.SelectedItem.ToString(); string s = txtRestrictions.Text; DataTable dt; if (s == string.Empty) { dt = schema.GetSchema(schemaName); } else { string[] restrictions = s.Split(','); dt = schema.GetSchema(schemaName, restrictions); } gridView.DataSource = dt; }
/// <summary> /// 加载数据表 /// </summary> /// <param name="connectionName"></param> private void LoadTable(String connectionName) { // 加载数据库 nowConnectionName = connectionName; var dal = new DbConnConfigDAL(); var model = dal.FindOne(connectionName); this.nowDbSchema = DbSchemaFactory.Create(new MySqlDatabase(model.ConnectionString, MySqlClientFactory.Instance)); try { nowDb = this.nowDbSchema.GetDatabase(model.DefaultDb); } catch (Exception e1) { MsgBox.ShowErrorMessage("数据库打开失败:" + e1.Message); return; } // 加载表 this.listBox1.Items.Clear(); this.listBox2.Items.Clear(); this.unSelectedTableList.Clear(); this.selectedTableList.Clear(); foreach (SOTable t in nowDb.TableList) { listBox1.Items.Add(t); unSelectedTableList.Add(t); } }
public void DbSchema_CompoundKey() { StoreItemCollection ssdl = LoadSSDL("CompoundKey"); DbSchema schema = DbSchemaFactory.CreateDbSchema(ssdl); DbContainer container = new DbContainer(new DbContainerParameters()); container.Initialize(schema); }
public void Initialize(StoreItemCollection edmStoreSchema) { if (this.IsInitialized(edmStoreSchema)) { return; } DbSchema schema = DbSchemaStore.GetDbSchema( edmStoreSchema, sic => DbSchemaFactory.CreateDbSchema(sic)); this.Initialize(schema); }
private void cbConnectionStrings_SelectedIndexChanged(object sender, EventArgs e) { tvDatabase.Nodes.Clear(); var dal = new DbConnDAL(); var model = dal.FindOne(cbConnectionStrings.SelectedItem.ToString()); var tmpDbSchema = DbSchemaFactory.Create(model.Name); Main m = this.ParentForm as Main; m.ClearDbList(); IList <SODatabase> dbList = null; this.Cursor = Cursors.WaitCursor; try { dbList = tmpDbSchema.GetDatabaseList(); } catch (Exception e1) { MsgBox.ShowErrorMessage("数据库连接异常:" + e1.Message); return; } finally { this.Cursor = Cursors.Default; } this.dbSchema = tmpDbSchema; DbSchemaHelper.Instance.CurrentSchema = dbSchema; TreeNode root = new TreeNode(model.Name, 0, 0); root.ToolTipText = model.ConnectionString; tvDatabase.Nodes.Add(root); foreach (SODatabase db in dbList) { TreeNode dbNode = new TreeNode(db.Name, 1, 1); dbNode.Tag = db; dbNode.ToolTipText = string.IsNullOrEmpty(db.Comment) ? db.Name : db.Comment; dbNode.ContextMenuStrip = cmsDatabase; root.Nodes.Add(dbNode); MainForm.AddDbListItem(db); } root.Expand(); }
private void BeegoProjectCodeBuilder_Load(object sender, EventArgs e) { RefreshDatabase(); currentDatabase = Config.MainForm.toolItemDbList.SelectedItem as SODatabase; tableList = currentDatabase.TableList; cbConnectStringName.SelectedValue = currentDatabase.Parent.DbProvider.ConnectionString; cbConnectStringName.Enabled = false; DbSchema dbSchema = DbSchemaFactory.Create(((ComboBoxItem)cbConnectStringName.SelectedItem).Text); IList <SODatabase> dbList = dbSchema.GetDatabaseList(); cmbDatabase.Items.Clear(); cmbDatabase.DataSource = dbList; cmbDatabase.Text = currentDatabase.Name; this.Height -= gbTableSelect.Height; this.Height += gbApiSetting.Height; }
//改变连接 void ChangeConnection(string csName) { DbConnDAL dal = new DbConnDAL(); var model = dal.FindOne(csName); currentSchema = DbSchemaFactory.Create(model.Name); List <SODatabase> dbList = currentSchema.GetDatabaseList(); cbDatabase.Items.Clear(); foreach (SODatabase db in dbList) { if (db.IsSystemDatabase) { continue; } cbDatabase.Items.Add(db); } //if (cbDatabase.Items.Count > 0) //{ // DbName = cbDatabase.Items[0].ToString(); // cbDatabase.SelectedIndex = 0; //} //else //{ // DbName = string.Empty; //} foreach (object item in cbConnectionStrings.Items) { if (item.ToString() == CSName) { cbConnectionStrings.SelectedItem = item; break; } } }
//改变连接 void ChangeConnection(string csName) { ConnectionStringSettings css = ConfigurationManager.ConnectionStrings[csName]; currentSchema = DbSchemaFactory.Create(css.Name); List <SODatabase> dbList = currentSchema.GetDatabaseList(); cbDatabase.Items.Clear(); foreach (SODatabase db in dbList) { if (db.IsSystemDatabase) { continue; } cbDatabase.Items.Add(db); } //if (cbDatabase.Items.Count > 0) //{ // DbName = cbDatabase.Items[0].ToString(); // cbDatabase.SelectedIndex = 0; //} //else //{ // DbName = string.Empty; //} foreach (object item in cbConnectionStrings.Items) { if (item.ToString() == CSName) { cbConnectionStrings.SelectedItem = item; break; } } }
private void cbConnectionStrings_SelectedIndexChanged(object sender, EventArgs e) { tvDatabase.Nodes.Clear(); ConnectionStringSettings css = ConfigurationManager.ConnectionStrings[cbConnectionStrings.SelectedItem.ToString()]; dbSchema = DbSchemaFactory.Create(css.Name); DbSchemaHelper.Instance.CurrentSchema = dbSchema; TreeNode root = new TreeNode(css.Name, 0, 0); root.ToolTipText = css.ConnectionString; tvDatabase.Nodes.Add(root); Main m = this.ParentForm as Main; m.ClearDbList(); this.Cursor = Cursors.WaitCursor; IList <SODatabase> dbList = dbSchema.GetDatabaseList(); this.Cursor = Cursors.Default; foreach (SODatabase db in dbList) { TreeNode dbNode = new TreeNode(db.Name, 1, 1); dbNode.Tag = db; dbNode.ToolTipText = string.IsNullOrEmpty(db.Comment) ? db.Name : db.Comment; dbNode.ContextMenuStrip = cmsDatabase; root.Nodes.Add(dbNode); MainForm.AddDbListItem(db); } root.Expand(); }