v6maro
[H]ard|Gawd
- Joined
- Oct 10, 2002
- Messages
- 1,552
Ok, I have sql query where I fill a dataset. The sql query has 4 queries, so 4 datatables are returned to the dataset.
Table
Table1
Table2
Table3
Table is unique and has every Employee Number (all unique)
---------
EmpNo
10001
10002
10003
...
Table1 is a result set of Employee Numbers between two dates, so there are duplicates of the same EmpNo. This table also includes Employee Name, last name, etc..
[Table1]
---------
EmpNo
Fname
Lname
10001 John Doe
10001 John Doe
10002 Jane Smith
10002 Jane Smith
...
Table2 is a result set of Employee Numbers, the start date, end date, and 3 deduction columns. Since an Employee can have multiple checks over a single month, EmpNo is duplicated here as well.
[Table2]
---------
EmpNo
WeekEnd
CheckDate
DedNo 1
DedNo 2
DedNo 3
10001 05-06-2007 05-11-2007 1 0 0
10001 05-20-2007 05-25-2007 1 0 0
10002 05-06-2007 05-11-2007 1 0 0
10002 05-20-2007 05-25-2007 1 0 0
...
Table3 is a result set of Employee Numbers, start date, end date, Earnings 1, Hours 1, Earnings 2, Hours 2. Since an Employee can have multiple checks over a single month, EmpNo is duplicated here as well.
[Table3]
---------
EmpNo
WeekEnd
CheckDate
Earnings 1
Hours 1
Earnings 2
Hours 2
10001 05-06-2007 05-11-2007 923.00 80.00 .00 .00
10001 05-20-2007 05-25-2007 923.00 80.00 .00 .00
10002 05-06-2007 05-11-2007 311.00 56.98 .00 .00
10002 05-20-2007 05-25-2007 311.00 56.98 .00 .00
...
Ok, after I have all this data, I need to make one large dataset in C#
like so:
EmpNo
WeekEnd
CheckDate
Fname
Lname
DedNo1
DedNo2
DedNo3
Earnings1
Hours1
Earnings2
Hours2
So, how would one combine these via datasets in c# like above?
I have tried DataTable.Merge(sourceTable);
That results in this:
Obviously not what I want.
I have tried adding a 'MasterTable' to the dataset, setting the unique table as the main one, using relations to relate them all, then using a DataSetHelper class calling InsertJoinInto but I keep getting errors saying not unique fields, this is really driving me crazy.
Any help would be greatly appreciated
Table
Table1
Table2
Table3
Table is unique and has every Employee Number (all unique)
---------
EmpNo
10001
10002
10003
...
Table1 is a result set of Employee Numbers between two dates, so there are duplicates of the same EmpNo. This table also includes Employee Name, last name, etc..
[Table1]
---------
EmpNo
Fname
Lname
10001 John Doe
10001 John Doe
10002 Jane Smith
10002 Jane Smith
...
Table2 is a result set of Employee Numbers, the start date, end date, and 3 deduction columns. Since an Employee can have multiple checks over a single month, EmpNo is duplicated here as well.
[Table2]
---------
EmpNo
WeekEnd
CheckDate
DedNo 1
DedNo 2
DedNo 3
10001 05-06-2007 05-11-2007 1 0 0
10001 05-20-2007 05-25-2007 1 0 0
10002 05-06-2007 05-11-2007 1 0 0
10002 05-20-2007 05-25-2007 1 0 0
...
Table3 is a result set of Employee Numbers, start date, end date, Earnings 1, Hours 1, Earnings 2, Hours 2. Since an Employee can have multiple checks over a single month, EmpNo is duplicated here as well.
[Table3]
---------
EmpNo
WeekEnd
CheckDate
Earnings 1
Hours 1
Earnings 2
Hours 2
10001 05-06-2007 05-11-2007 923.00 80.00 .00 .00
10001 05-20-2007 05-25-2007 923.00 80.00 .00 .00
10002 05-06-2007 05-11-2007 311.00 56.98 .00 .00
10002 05-20-2007 05-25-2007 311.00 56.98 .00 .00
...
Ok, after I have all this data, I need to make one large dataset in C#
like so:
EmpNo
WeekEnd
CheckDate
Fname
Lname
DedNo1
DedNo2
DedNo3
Earnings1
Hours1
Earnings2
Hours2
Code:
10001 05-06-2007 05-11-2007 John Doe 0 0 1 923.00 80.00 .00 .00
10001 05-20-2007 05-25-2007 John Doe 0 0 1 923.00 80.00 .00 .00
10001 05-06-2007 05-11-2007 Jane Smith 0 0 1 311.00 56.98 .00 .00
10001 05-20-2007 05-25-2007 Jane Smith 0 0 1 311.00 56.98 .00 .00
I have tried DataTable.Merge(sourceTable);
That results in this:
Code:
10001 05-06-2007 05-11-2007 John Doe
10001 05-20-2007 05-25-2007 John Doe
10002 05-06-2007 05-11-2007 Jane Smith
10002 05-20-2007 05-25-2007 Jane Smith
10001 05-06-2007 05-11-2007 0 0 1
10001 05-20-2007 05-25-2007 0 0 1
10002 05-06-2007 05-11-2007 0 0 1
10002 05-20-2007 05-25-2007 0 0 1
10001 05-06-2007 05-11-2007 923.00 80.00 .00 .00
10001 05-20-2007 05-25-2007 923.00 80.00 .00 .00
10002 05-06-2007 05-11-2007 311.00 56.98 .00 .00
10002 05-20-2007 05-25-2007 311.00 56.98 .00 .00
I have tried adding a 'MasterTable' to the dataset, setting the unique table as the main one, using relations to relate them all, then using a DataSetHelper class calling InsertJoinInto but I keep getting errors saying not unique fields, this is really driving me crazy.
Any help would be greatly appreciated