Пример #1
0
        //***************************************************************************
        // Private Methods
        //
        private void PopulateTableList()
        {
            this.lstSrcTables.BeginUpdate();
            this.lstSrcTables.Items.Clear();
            try
            {
                if (this._db.GetType().Name != "rsDbSql")
                {
                    throw new Exception("Export wizrd currently only support SQL database sources.");
                }

                rsDbSql  db   = (rsDbSql)this._db;
                string[] tbls = db.GetTableList(this._dbNm);
                for (int i = 0; i < tbls.Length; i++)
                {
                    this.lstSrcTables.Items.Add("T: " + tbls[i]);
                }

                string[] vws = db.GetViewList(this._dbNm);
                for (int i = 0; i < vws.Length; i++)
                {
                    this.lstSrcTables.Items.Add("V: " + vws[i]);
                }
            }
            catch (Exception ex)
            {
                CrossThreadUI.ShowMessageBox(this, "Unable to retrieve table names: " + ex.Message, "Unexpected Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                this.Dispose();
            }
            finally
            {
                this.lstSrcTables.EndUpdate();
            }
        }
Пример #2
0
        private void RefreshTableList(TreeNode nd)
        {
            nd.Text += " (expanding...)";
            Application.DoEvents();
            this.BeginUpdate();
            this.UseWaitCursor = true;
            rsDbSql dbConn = this.GetDbObject(nd);

            try
            {
                nd.Nodes.Clear();
                string[] objList = null;
                if ((SqlObjType)nd.Tag == SqlObjType.TableGroup)
                {
                    objList = dbConn.GetTableList(nd.Parent.Text);
                }
                else
                {
                    objList = dbConn.GetViewList(nd.Parent.Text);
                }
                foreach (string tbl in objList)
                {
                    TreeNode ndTbl = new TreeNode(tbl);
                    ndTbl.Name = string.Format("{0}.{1}", nd.Parent.Text, tbl);
                    if ((SqlObjType)nd.Tag == SqlObjType.TableGroup)
                    {
                        ndTbl.Tag = SqlObjType.Table;
                        ndTbl.ContextMenuStrip = this.mnuNdScript;
                    }
                    else
                    {
                        ndTbl.Tag = SqlObjType.View;
                        ndTbl.ContextMenuStrip = this.mnuNdObj;
                    }
                    ndTbl.ImageIndex         = ((SqlObjType)ndTbl.Tag == SqlObjType.Table) ? 2 : 8;
                    ndTbl.SelectedImageIndex = ((SqlObjType)ndTbl.Tag == SqlObjType.Table) ? 2 : 8;
                    ndTbl.ImageKey           = ndTbl.SelectedImageKey = ((SqlObjType)ndTbl.Tag).ToString(); // == SqlObjType.Table) ? "Table" : "StoredProc";
                    TreeNode ndColumns = new TreeNode("Columns");
                    ndColumns.Nodes.Add("<EMPTY>");
                    ndColumns.Tag = SqlObjType.ColumnGroup;
                    ndColumns.ContextMenuStrip = this.mnuNdGroup;
                    ndTbl.Nodes.Add(ndColumns);
                    if ((SqlObjType)ndTbl.Tag == SqlObjType.Table)
                    {
                        TreeNode ndKeys = new TreeNode("Keys");
                        ndKeys.Nodes.Add("<EMPTY>");
                        ndKeys.Tag = SqlObjType.KeyGroup;
                        ndKeys.ContextMenuStrip = this.mnuNdGroup;
                        ndTbl.Nodes.Add(ndKeys);
                        TreeNode ndConstraints = new TreeNode("Constraints");
                        ndConstraints.Nodes.Add("<EMPTY>");
                        ndConstraints.Tag = SqlObjType.ConstraintGroup;
                        ndConstraints.ContextMenuStrip = this.mnuNdGroup;
                        ndTbl.Nodes.Add(ndConstraints);
                    }
                    TreeNode ndTriggers = new TreeNode("Triggers");
                    ndTriggers.Nodes.Add("<EMPTY>");
                    ndTriggers.Tag = SqlObjType.TriggerGroup;
                    ndTriggers.ContextMenuStrip = this.mnuNdGroup;
                    ndTbl.Nodes.Add(ndTriggers);
                    TreeNode ndIndexes = new TreeNode("Indexes");
                    ndIndexes.Nodes.Add("<EMPTY>");
                    ndIndexes.Tag = SqlObjType.IndexGroup;
                    ndIndexes.ContextMenuStrip = this.mnuNdGroup;
                    ndTbl.Nodes.Add(ndIndexes);
                    nd.Nodes.Add(ndTbl);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, string.Format("Unable to retreive the list of tables from the SQL server:\n\n{0}\n\nApplication Version: {1}", ex.Message, Application.ProductVersion), "Error");
                nd.Nodes.Clear();
                nd.Nodes.Add("<EMPTY>");
                nd.Collapse(false);
            }
            finally
            {
                nd.Text = nd.Text.Substring(0, nd.Text.LastIndexOf('(')).TrimEnd();
                this.EndUpdate();
                this.UseWaitCursor = false;
            }
        }