Exemplo n.º 1
0
        //show all button click
        private void button1_Click(object sender, EventArgs e)
        {
            BugHistory vu = new BugHistory();
            DataTable  dt = vu.Select_bugs();

            dgv_history.DataSource = dt;
        }
Exemplo n.º 2
0
        private void BugHistory_Load(object sender, EventArgs e)
        {
            //creating datatable to hold the categories from database
            //to get project titile  from database
            MySqlConnection conn = new MySqlConnection("server = localhost; user id = root; database = bugtracker");
            MySqlDataReader myreader;

            try
            {
                //getting data from database using dataadapter
                MySqlCommand sda = new MySqlCommand("Select BugTitle from bug", conn);
                //Create a Datatable to hold the records from database
                //Step 5:Open Connection
                conn.Open();
                myreader = sda.ExecuteReader();
                while (myreader.Read())
                {
                    cmb_bugname.Items.Add(myreader.GetValue(0).ToString());
                }
                conn.Close();
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
            finally
            {
                //Step 8: Close Connection
                conn.Close();
            }

            // Data Grid View
            BugHistory vu = new BugHistory();
            DataTable  dt = vu.Select_bugs();

            dgv_history.DataSource = dt;
        }