Ejemplo n.º 1
0
        private void Form3_Load(object sender, EventArgs e)
        {
            this.Text = string.Format(Tag.ToString(), table);
            string s_sql = AppFunc.GetSql(conStr, 3, table);

            dataGridView1.DataSource = AppFunc.GetData(conStr, s_sql);
        }
Ejemplo n.º 2
0
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            if (conStr == null)
            {
                toolStripButton1_Click(null, null);
            }
            if (conStr == null)
            {
                return;
            }
            richTextBox2.Text = "";
            string s_sql = richTextBox1.SelectedText.Trim();

            if (string.IsNullOrEmpty(s_sql))
            {
                s_sql = richTextBox1.Text;
            }
            if (s_sql.ToLower().StartsWith("select"))
            {
                dataGridView1.DataSource = null;
                try
                {
                    dataGridView1.DataSource  = AppFunc.GetData(conStr, s_sql);
                    tabControl1.SelectedIndex = 0;
                }
                catch (Exception ex)
                {
                    richTextBox2.Text         = ex.ToString();
                    tabControl1.SelectedIndex = 1;
                }
            }
            else
            {
                dataGridView1.DataSource = null;
                try
                {
                    int ret = AppFunc.ExecuteNonQuery(conStr, s_sql);
                    richTextBox2.Text         = string.Format("执行语句成功,影响{0}行", ret);
                    tabControl1.SelectedIndex = 1;
                }
                catch (Exception ex)
                {
                    richTextBox2.Text         = ex.ToString();
                    tabControl1.SelectedIndex = 1;
                }
            }
        }
Ejemplo n.º 3
0
        void LoadDb()
        {
            treeView1.Nodes.Clear();
            string    s_table  = AppFunc.GetSql(conStr, 1);
            string    s_view   = AppFunc.GetSql(conStr, 2);
            DataTable table1   = AppFunc.GetData(conStr, s_table);
            DataTable table2   = AppFunc.GetData(conStr, s_view);
            TreeNode  rootNode = new TreeNode(conStr.Database);
            var       nodes    = treeView1.Nodes.Find(conStr.Database, false);

            if (nodes != null && nodes.Length > 0)
            {
                rootNode = nodes[0];
            }
            else
            {
                treeView1.Nodes.Add(rootNode);
            }
            SetTreeview(1, rootNode, table1);
            SetTreeview(2, rootNode, table2);
        }