public static void EditTable() { IObjectExplorerService srv = HostServicesSingleton.HostServices.ObjectExplorerService; if (srv == null) { MessageService.ShowError("No object explorer available!"); return; } if (srv.SelNode == null || srv.SelNode.ConnParams == null) { MessageService.ShowError("Database data is not available!"); return; } int type = srv.SelNode.Type; if (type != DBObjectType.UserTable) { MessageService.ShowError("Selected node is not a user defined table!"); return; } frmTableEdit frm = new frmTableEdit(); frm.Caption = String.Format("{0} ({1} on {2})", srv.SelNode.Name, srv.SelNode.ServerName, srv.SelNode.DatabaseName); frm.ConnectionParams = srv.SelNode.ConnParams.CreateCopy(); frm.ConnectionParams.Database = srv.SelNode.DatabaseName; frm.TableEdit.ModifyTable(frm.ConnectionParams, srv.SelNode.id); HostServicesSingleton.HostServices.ShowForm(frm, AddInDockState.Document); }
public static void CreateTable( ) { IObjectExplorerService srv = HostServicesSingleton.HostServices.ObjectExplorerService; if (srv == null) { MessageService.ShowError("No object explorer available!"); return; } if (srv.SelNode == null || srv.SelNode.ConnParams == null) { MessageService.ShowError("Database data is not available!"); return; } if (String.IsNullOrEmpty(srv.SelNode.ConnParams.Database)) { MessageService.ShowError("Selected node is not a database or child of a database!"); return; } frmTableEdit frm = new frmTableEdit(); frm.Caption = String.Format("New Table ({0} on {1})", srv.SelNode.ServerName, srv.SelNode.DatabaseName); frm.ConnectionParams = srv.SelNode.ConnParams.CreateCopy(); frm.ConnectionParams.Database = srv.SelNode.DatabaseName; frm.TableEdit.CreateTable(frm.ConnectionParams); HostServicesSingleton.HostServices.ShowForm(frm, AddInDockState.Document); }