예제 #1
0
        private void load_dataGrid()
        {
            try
            {
                MySqlConnection connection = DBConnection.Conn();
                MySqlCommand    command    = connection.CreateCommand();
                MySqlDataReader reader;
                command.CommandText = "SELECT id,nombre,cantidad,precio,subtotal FROM productos";

                connection.Open();
                reader = command.ExecuteReader();

                while (reader.Read())
                {
                    this.dataGridView1.Rows.Add(reader.GetValue(0), reader.GetValue(1), reader.GetValue(2), reader.GetValue(3), reader.GetValue(4), new DataGridViewButtonCell().Value = "Eliminar");
                }

                connection.Close();
            }
            catch (MySqlException ex)
            {
                Console.WriteLine(ex);
            }
        }