Click here to Skip to main content
15,921,382 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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);
	.
	.
	.
	.
	.
    }

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.
Posted
Updated 15-Dec-10 7:40am
v2
Comments
AspDotNetDev 15-Dec-10 13:33pm    
You should wrap your code in PRE blocks with the lang attribute set to "C#".
TweakBird 15-Dec-10 13:41pm    
Edited for code blocks. Please use <pre> tag for code blocks.
Pete O'Hanlon 15-Dec-10 15:29pm    
You have an answer. You should accept it as the answer so that everybody knows what the solution is.

1 solution

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.
 
Share this answer
 
Comments
gcryall 15-Dec-10 15:11pm    
Thanks a bunch Marc. Thats exactly what it was, and I probably never would have found it if you hadn't told me.

Thanks again
Marc A. Brown 15-Dec-10 15:13pm    
You're quite welcome. Glad I could help. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900