public static IList<string> getTableNames(string dbname)
        {
            List<string> ret = new List<string>();
            DataTable schema = null;

            using (MySQLDAO.MySQLDAOContext con = new MySQLDAO.MySQLDAOContext(MySQLConString.getStaticConstring()))
            {
                con.OpenConnection();

                MySQLSchemaDAO dao = new MySQLSchemaDAO(con);
                schema = dao.selectTables(dbname);

                con.CloseConnection();
            }

            if (schema != null)
            {
                foreach (DataRow row in schema.Rows)
                {
                    ret.Add(row["table_name"].ToString());
                }
            }

            return ret;
        }
예제 #2
0
        private void btnReadColumn_Click(object sender, EventArgs e)
        {
            try
            {
                MySQLDAO.MySQLConString objConString = this.getObjConstring();

                DataTable schema = null;

                using (MySQLDAO.MySQLDAOContext con = new MySQLDAO.MySQLDAOContext(objConString.ConString))
                {
                    con.OpenConnection();

                    MySQLSchemaDAO dao = new MySQLSchemaDAO(con);
                    schema = dao.selectTableColumns(tbxDbName.Text, tbxTableName.Text);

                    con.CloseConnection();
                }

                if (schema != null)
                {
                    this.dataSource.Clear();
                    this.cmbColumns.Items.Clear();
                    foreach (DataRow row in schema.Rows)
                    {
                        this.dataSource.Add(new CustomDataMySQLTable(row["COLUMN_NAME"].ToString(), row["DATA_TYPE"].ToString(), "",""));
                        this.cmbColumns.Items.Add(row["COLUMN_NAME"].ToString());
                        this.cmbNullColumns.Items.Add(row["COLUMN_NAME"].ToString());
                    }
                }

                this.grid.DataSource = this.dataSource;
                if (this.cmbColumns.Items.Count > 0)
                {
                    this.cmbColumns.SelectedIndex = 0;
                }
                if (this.cmbNullColumns.Items.Count > 0)
                {
                    this.cmbNullColumns.SelectedIndex = 0;
                }
            }
            catch (Exception excp)
            {
                MessageBox.Show("エラーが発生しました。MySQLが起動しているかご確認下さい。");
                return;
            }
        }