Results 1 to 2 of 2

Thread: adding rows to dataset table manually after retrieving from DB

  1. #1

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    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

  2. #2

    Thread Starter
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: adding rows to dataset table manually after retrieving from DB

    Here's what I have so far, and it works:
    VB Code:
    1. Public Function FetchDisplayAFRs(ByVal DivisionKey As Integer, ByVal OperatingUnitKey As Integer, ByVal BusinessUnitKey As Integer, ByVal Year As Integer) As DataSet
    2.         Dim ds As System.Data.DataSet = New DataAccess.AFR(_ConnString).FetchDisplayAFRs(DivisionKey, OperatingUnitKey, BusinessUnitKey, Year)
    3.         Dim CurrentRow As Integer
    4.         Dim MonthNum As Integer
    5.         For MonthNum = 1 To 12
    6.             Dim Woof(6) As Object
    7.             Woof(0) = DivisionKey
    8.             Woof(1) = OperatingUnitKey
    9.             Woof(2) = BusinessUnitKey
    10.             Woof(3) = MonthNum
    11.             Woof(4) = Year
    12.             Woof(5) = 0
    13.             Woof(6) = 0
    14.             ds.Tables.Item(0).Rows.Add(Woof)
    15.         Next
    16.         Return ds
    17.     End Function
    Hope that helps.

    woka

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width