adding rows to dataset table manually after retrieving from DB
I return a dataset from a function.
This has 3 fields.
Month, WorkHrs, ContractWrkHrs
So the data may look like:
Code:
1, 45, 234
3, 23, 98
11, 19, 101
So, the months are January, March and Novemeber.
before I pass this data to a datagrid to bind I would like to add all the other months. so the data in the dataset will be:
Code:
1, 45, 234
2, 0, 0
3, 23, 98
4, 0, 0
5, 0, 0
6, 0, 0
etc
How would I do this?
I basically want to show Jan to Dec in a grid whether they exist or not in the DB.
Woka
Re: adding rows to dataset table manually after retrieving from DB
Here's what I have so far, and it works:
VB Code:
Public Function FetchDisplayAFRs(ByVal DivisionKey As Integer, ByVal OperatingUnitKey As Integer, ByVal BusinessUnitKey As Integer, ByVal Year As Integer) As DataSet
Dim ds As System.Data.DataSet = New DataAccess.AFR(_ConnString).FetchDisplayAFRs(DivisionKey, OperatingUnitKey, BusinessUnitKey, Year)
Dim CurrentRow As Integer
Dim MonthNum As Integer
For MonthNum = 1 To 12
Dim Woof(6) As Object
Woof(0) = DivisionKey
Woof(1) = OperatingUnitKey
Woof(2) = BusinessUnitKey
Woof(3) = MonthNum
Woof(4) = Year
Woof(5) = 0
Woof(6) = 0
ds.Tables.Item(0).Rows.Add(Woof)
Next
Return ds
End Function
Hope that helps.
woka