private void LoadData() { try { CustomerAdapter adapter = new CustomerAdapter( SQLConnection.GetDataBase()); CustomerList = adapter.GetAllCustomer(); LV_Customer.ItemsSource = CustomerList.Tables[0].DefaultView; } catch (Exception ex) { MessageBox.Show("异常发生,请检查数据库连接", "错误", MessageBoxButton.OK, MessageBoxImage.Error); //写入日志 } }
//加载数据 private void LoadData() { try { customerList = adapter.GetAllCustomer(); LV_Customer.ItemsSource = customerList.Tables[0].DefaultView; } catch (Exception ex) { MessageBox.Show("异常发生,请检查数据库连接", "错误", MessageBoxButton.OK, MessageBoxImage.Error); //清除列表 LV_Customer.Items.Clear(); //写入日志 } }