Пример #1
0
        private void FormMainOrcl_Load(object sender, EventArgs e)
        {
            DataTable dt = (DbType == "Oracle")?DBconnectionOracle.ShowTableList():DBconnectionSQLServer.ShowTableList(DbName);

            foreach (DataRow row in dt.Rows)
            {
                int index = TableView.Rows.Add();
                TableView.Rows[index].Cells[0].Value = (DbType == "Oracle") ? row["table_name"].ToString():row["name"].ToString();
            }
            if (TableView.CurrentCell != null && TableView.CurrentCell.Value != null)
            {
                DataTable ds = (DbType == "Oracle") ? DBconnectionOracle.ShowTable(TableView.CurrentCell.Value.ToString()) : DBconnectionSQLServer.ShowTable(DbName, TableView.CurrentCell.Value.ToString());

                try
                {
                    DataView.DataSource = ds;//表从起始行显示在dataGridView里
                }
                catch (Exception)
                {
                    MessageBox.Show("数据未能正确获得,请重试", "ERROR",
                                    MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    System.Threading.Thread.CurrentThread.Abort();
                    //DBView.CurrentCell = DBView.Rows[0].Cells[0];
                }
            }
        }
Пример #2
0
        public static bool OracleCompareTable(string tableName)
        {
            DataTable dt = DBconnectionOracle.ShowTableList();

            foreach (DataRow row in dt.Rows)
            {
                if (row["table_name"].ToString() != "tempdb")
                {
                    if (tableName == row["table_name"].ToString())
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Пример #3
0
        private void FromXMLExecute_FormClosing(object sender, FormClosingEventArgs e)
        {
            //Do your stuff here.
            TableView.Rows.Clear();
            int       findIndex = 0;
            DataTable dt        = (DbType == "Oracle") ? DBconnectionOracle.ShowTableList() : DBconnectionSQLServer.ShowTableList(DbName);

            foreach (DataRow row in dt.Rows)
            {
                int index = TableView.Rows.Add();
                TableView.Rows[index].Cells[0].Value = (DbType == "Oracle") ? row["table_name"].ToString() : row["name"].ToString();
                string tableName = formxml.tableName;
                if (tableName != "")
                {
                    if ((string)TableView.Rows[index].Cells[0].Value == tableName)
                    {
                        findIndex = index;
                    }
                }
            }
            TableView.CurrentCell = TableView.Rows[findIndex].Cells[0];

            /*
             * if (TableView.CurrentCell != null && TableView.CurrentCell.Value != null)
             * {
             *  DataSet ds = (DbType == "Oracle") ? DBconnectionOracle.ShowTable(TableView.CurrentCell.Value.ToString()) : DBconnectionSQLServer.ShowTable(DbName, TableView.CurrentCell.Value.ToString());
             *
             *  try
             *  {
             *      DataView.DataSource = ds.Tables[0].DefaultView;//表从起始行显示在dataGridView里
             *  }
             *  catch (Exception)
             *  {
             *      MessageBox.Show("数据未能正确获得,请重试", "ERROR",
             *      MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             *      System.Threading.Thread.CurrentThread.Abort();
             *      //DBView.CurrentCell = DBView.Rows[0].Cells[0];
             *  }
             * }*/
        }