示例#1
0
        private void btnloaddata_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // Call the function from the View Model, then the View Model will call the
                // Model to execute these codes below and return the results here

                dataGridCustomers.DataContext = vm.CallDisplayProduct();

                /*
                 * conn.Open();
                 * MySqlCommand cmd = new MySqlCommand("SELECT * FROM product", conn);
                 * MySqlDataAdapter adp = new MySqlDataAdapter(cmd);
                 * DataSet ds = new DataSet();
                 * adp.Fill(ds, "LoadDataBinding");
                 * dataGridCustomers.DataContext = ds;
                 */
            }
            catch (MySqlException ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                conn.Close();
            }
        }
        private void btnloaddata_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                // Call the function from the View Model, then the View Model will call the
                // Model to execute these codes below and return the results here

                dataGridCustomers.DataContext = vm.CallDisplayProduct();
            }
            catch (MySqlException ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                conn.Close();
            }
        }