WPF困惑的问题 [英] WPF perplexing Problem

查看:88
本文介绍了WPF困惑的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试自学WPF编程,并且正在为一个令人困惑的问题而苦苦挣扎.

我有一个名为DM_EarningsDataSet的强类型数据集,用于跟踪我的兼职工作工资.

此数据集中有7个表(工作分配",公司",收入",员工",计划",费率"和特殊费率类型".

我没有列出xaml代码,但由于表格布局正确,它似乎还可以.

如果我运行以下代码,则可以正常工作.实际上,我使用的所有表格都使用相似的代码来引用相似的代码,并且适用于所有表格,但以下引用程序表的内容除外.

这段代码有效:

I am trying to teach myself WPF Programming and am having a struggle with a perplexing problem.

I have a strongly typed dataset named DM_EarningsDataSet which is used to track my part time job wages.

There are 7 tables in this dataset (Assignments, Companies, Earnings, Employees, Programs, Rates, and SpecialRateTypes.

I haven''t listed the xaml code, but it appears OK since the forms are laid out correctly.

If I run the following code, it works with no problems. In fact there is similar code in all the forms I am using referencing different tables using similar code, and it works for all forms except for the following which references the programs table.

This code works:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace DM_Earnings_System_WPF
{
  /// <summary>
  /// Interaction logic for frmRates.xaml
  /// </summary>
  public partial class frmRates : Window
  {
    public frmRates()
    {
      InitializeComponent();
    }
    private DM_EarningsDataSet RateData = new DM_EarningsDataSet();
    private DM_EarningsDataSetTableAdapters.RatesTableAdapter taRate = new DM_EarningsDataSetTableAdapters.RatesTableAdapter();
    private DM_EarningsDataSetTableAdapters.TableAdapterManager taManager = new DM_EarningsDataSetTableAdapters.TableAdapterManager();
    private CompanyLookupDataSet.CompaniesDataTable CompanyLookup = new CompanyLookupDataSet.CompaniesDataTable();
    private EmployeeLookupDataSet.EmployeesDataTable EmployeeLookup = new EmployeeLookupDataSet.EmployeesDataTable();
    private CollectionView RatesView;
    private void frmRates_Loaded(object sender, System.Windows.RoutedEventArgs e)
    {
      CompanyLookupDataSetTableAdapters.CompaniesTableAdapter taCompany = new CompanyLookupDataSetTableAdapters.CompaniesTableAdapter();
      taCompany.Fill(this.CompanyLookup);
      EmployeeLookupDataSetTableAdapters.EmployeesTableAdapter taEmployee = new EmployeeLookupDataSetTableAdapters.EmployeesTableAdapter();
      taEmployee.Fill(this.EmployeeLookup);
      this.taRate.Fill(this.RateData.Rates);
	.
	.
	.
	.
	.
    }



但是,当我运行以下代码时,使用完全相同的编码技术却会失败,但是使用的是不同的表单/表格



However, when I run the following code it fails using the exact same coding technique but for a different form/table

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace DM_Earnings_System_WPF
{
  /// <summary>
  /// Interaction logic for frmPrograms.xaml
  /// </summary>
  public partial class frmPrograms : Window
  {
    public frmPrograms()
    {
      InitializeComponent();
    }
    private DM_EarningsDataSet ProgramData = new DM_EarningsDataSet();
    private DM_EarningsDataSetTableAdapters.ProgramsTableAdapter taProgram = new DM_EarningsDataSetTableAdapters.ProgramsTableAdapter();
    private DM_EarningsDataSetTableAdapters.TableAdapterManager taProgramsManager = new DM_EarningsDataSetTableAdapters.TableAdapterManager();
    private CompanyLookupDataSet.CompaniesDataTable ProgramCompanyLookup = new CompanyLookupDataSet.CompaniesDataTable();
    private EmployeeLookupDataSet.EmployeesDataTable ProgramEmployeeLookup = new EmployeeLookupDataSet.EmployeesDataTable();
    private AssignmentsLookupDataSet.AssignmentsDataTable ProgramAssignmentLookup = new AssignmentsLookupDataSet.AssignmentsDataTable();
    private SpecialRateTypeLookupDataSet.SpecialRateTypesDataTable ProgramSpecialRateTypeLookup = new SpecialRateTypeLookupDataSet.SpecialRateTypesDataTable();
    private CollectionView ProgramsView;
    private void frmPrograms_Loaded(object sender, System.Windows.RoutedEventArgs e)
    {
        CompanyLookupDataSetTableAdapters.CompaniesTableAdapter taCompany = new CompanyLookupDataSetTableAdapters.CompaniesTableAdapter();
        taCompany.Fill(this.ProgramCompanyLookup);
        EmployeeLookupDataSetTableAdapters.EmployeesTableAdapter taEmployee = new EmployeeLookupDataSetTableAdapters.EmployeesTableAdapter();
        taEmployee.Fill(this.ProgramEmployeeLookup);
        AssignmentsLookupDataSetTableAdapters.AssignmentsTableAdapter taAssignment = new AssignmentsLookupDataSetTableAdapters.AssignmentsTableAdapter();
        taAssignment.Fill(this.ProgramAssignmentLookup);
        SpecialRateTypeLookupDataSetTableAdapters.SpecialRateTypesTableAdapter taSpecialRateType = new SpecialRateTypeLookupDataSetTableAdapters.SpecialRateTypesTableAdapter();
        taSpecialRateType.Fill(this.ProgramSpecialRateTypeLookup);
        this.taProgram.Fill(this.ProgramData.Programs);
	.
	.
	.
	.
	.
    }


我收到以下错误:"No value given for one or more required parameters", on the "this.taProgram.Fill(this.ProgramData.Programs);"语句.

我知道我可能缺少一些非常愚蠢的东西,但是我似乎无法弄清楚.

任何帮助将不胜感激.


I get the following error: "No value given for one or more required parameters", on the "this.taProgram.Fill(this.ProgramData.Programs);" statement.

I know I am probably missing something very stupid, but I can''t seem to figure this out.

Any help would be greatly appreciated.

推荐答案

该错误消息听起来像是一个SQL错误,可疑的是-通常是拼写错误的字段名.当然,我在您的代码中看不到SQL,但是也许您应该查看DM_EarningsDataSet.Programs来了解发生了什么.
That error message sounds suspiciously like an SQL error -- typically a misspelled field name. Of course, I see no SQL in your code, but perhaps you should look at DM_EarningsDataSet.Programs to see what''s going on.


这篇关于WPF困惑的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆