示例#1
0
        private void treeDb_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (!db.IsOpen)
            {
                return;
            }

            dataGrid.SuspendLayout();
            if (e.Node.ImageIndex == 0)
            {   // Database node
                dataGrid.ReadOnly   = true;
                dataGrid.DataSource = DatabaseInfoLocale(db.DatabaseInfo);
                rtbDdl.Text         = db.GetDatabaseDdl();
                sqlParserDdl.Update();
            }
            else
            {   // Table node
                dataGrid.ReadOnly = cbReadOnly.SelectedIndex == 0;
                dataGrid.Columns.Clear();
                if (tabControl1.SelectedIndex == 0)
                {
                    dataGrid.DataSource = db.GetTableData(e.Node.Text, null, SortOrder.None);
                    rtbDdl.Text         = db.GetTableDdl(e.Node.Name, true, true, true, true);
                }
                else
                {
                    rtbDdl.Text         = db.GetTableDdl(e.Node.Name, true, true, true, true);
                    dataGrid.DataSource = db.GetTableData(e.Node.Text, null, SortOrder.None);
                }
            }
            dataGrid.AllowUserToAddRows = dataGrid.AllowUserToDeleteRows = !dataGrid.ReadOnly;
            dataGrid.ResumeLayout();
        }
示例#2
0
        private string GetExportConstraintsSchema(SqlCeDb db, TreeView treeView)
        {
            List <string> ddl = new List <string>(Regex.Split(db.GetDatabaseDdl(), @";\s*").Where(s => !string.IsNullOrWhiteSpace(s)));

            for (int i = ddl.Count - 1; i >= 0; i--)
            {
                if (ddl[i].StartsWith("CREATE TABLE "))
                {
                    ddl.RemoveAt(i);
                }
            }
            return(RemoveUncheck(ddl, treeView));
        }