CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2001
    Posts
    1

    Populate Recordset

    I need a way to be able to populate a recordset. I have an Access database created and need to enter a list of times and dates for a year. I was wondering if their is a way to automatically populate these so I don't have to enter them all in. Thank You. Ted


  2. #2
    Join Date
    Jan 2000
    Location
    MO, USA
    Posts
    1,506

    Re: Populate Recordset

    where are you getting this information from? a text file? - your head? - someone else's head? - another database? each of those options have a different way of getting the info into the database.

    john

    John Pirkey
    MCSD
    http://www.ShallowWaterSystems.com
    http://www.stlvbug.org
    John Pirkey
    MCSD (VB6)
    http://www.stlvbug.org

  3. #3
    Join Date
    Jan 2000
    Location
    MO, USA
    Posts
    1,506

    Re: Populate Recordset

    You could write a script to do this. maybe, something like this:

    'psuedo code

    'open your connection, named cn

    dim sql as string
    dim i as integer, j as integer

    'since you are needing an entry for every half-hour for a work day - go through a loop
    'and add rows...

    for i = 8 to 17
    sql = "INSERT INTO YourTable (TimePeriod) VALUES "
    sql = sql & "('" & i & ":00')"

    cn.Execute sql, adExecuteNoRecords

    sql = "INSERT INTO YourTable (TimePeriod) VALUES "
    sql = sql & "('" & i & ":30')"

    cn.Execute sql, adExecuteNoRecords

    next i




    it adds an entry for 5:30 PM though - you could easily put a check in for " if i = 17 then dont do the :30 insert".

    If you need to do this for each day in the year, you'll have to put this inside another loop that go through the days. the trick there will be determining the weekends versus the work-week.

    hope this helps,

    john


    John Pirkey
    MCSD
    http://www.ShallowWaterSystems.com
    http://www.stlvbug.org
    John Pirkey
    MCSD (VB6)
    http://www.stlvbug.org

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

Featured