Exemplo n.º 1
0
        public static void ExecuteQuery(string qry)
        {
            //if (ConnectionStatus() == false || qry == "")
            //{
            MysqlInterface.close();
            MysqlInterface.init();
            //}

            MySqlCommand cmd = new MySqlCommand();

            cmd.Connection  = con;
            cmd.CommandText = qry;
            int numRowsUpdated = cmd.ExecuteNonQuery();

            cmd.Dispose();
        }
Exemplo n.º 2
0
        private void fmImport_Load(object sender, EventArgs e)
        {
            DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn();
            string column = "Columns";

            col.HeaderText = column;
            col.Name       = "f" + column;
            dgXLTable.Columns.Add(col);

            col            = new DataGridViewTextBoxColumn();
            col.HeaderText = column;
            col.Name       = "f" + column;
            dgXLTransfer.Columns.Add(col);

            col            = new DataGridViewTextBoxColumn();
            col.HeaderText = column;
            col.Name       = "f" + column;
            dgCWTransfer.Columns.Add(col);

            col            = new DataGridViewTextBoxColumn();
            col.HeaderText = column;
            col.Name       = "f" + column;
            dgCWTable.Columns.Add(col);

            try
            {
                MySqlDataReader rdr   = null;
                string          table = "";

                rdr = MysqlInterface.DoQuery("SHOW TABLES;");

                while (rdr.Read())
                {
                    table = rdr.GetString(0);
                    cbTable.Items.Add(table);
                }
            }
            catch (MySqlException ex)
            {
                Console.WriteLine("Error: {0}", ex.ToString());
            }
            finally
            {
                MysqlInterface.close();
            }
        }
Exemplo n.º 3
0
        //string stm = "SELECT id, description, purchase_price FROM part"

        public static MySqlDataReader DoQuery(string qry)
        {
            try
            {
                MysqlInterface.close();
                MysqlInterface.init();
                MySqlDataReader rdr = null;
                MySqlCommand    cmd = new MySqlCommand(qry, con);
                rdr = cmd.ExecuteReader();
                cmd.Dispose();
                return(rdr);
            }
            catch (MySqlException err)
            {
                Console.WriteLine("Error: " + err.ToString());
                return(null);
            }
        }
Exemplo n.º 4
0
        private void cbTable_SelectedIndexChanged(object sender, EventArgs e)
        {
            dgCWTable.RowCount = 1;
            dgCWTable.Rows.Clear();
            dgCWTable.Columns.Clear();
            dgCWTable.AutoGenerateColumns = false;
            try
            {
                MySqlDataReader rdr    = null;
                string          table  = cbTable.Text;
                string          column = "";

                rdr = MysqlInterface.DoQuery("SHOW COLUMNS FROM " + table + ";");
                DataGridViewTextBoxColumn col = new DataGridViewTextBoxColumn();
                column         = "Columns";
                col.HeaderText = column;
                col.Name       = "f" + column;
                dgCWTable.Columns.Add(col);


                while (rdr.Read())
                {
                    column = rdr.GetString(0);
                    string[] row = { column };
                    dgCWTable.Rows.Add(row);
                }
            }
            catch (MySqlException ex)
            {
                Console.WriteLine("Error: {0}", ex.ToString());
            }
            finally
            {
                MysqlInterface.close();
            }
        }