Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. How do you populate an array with dataset values

How do you populate an array with dataset values

Scheduled Pinned Locked Moved Visual Basic
databasedata-structures
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    directred
    wrote on last edited by
    #1

    I am using VB 2005 and have connected to an Access database. Rather than do the usual for i = 0 to total, can you populate an array with the dataset some how.

    0 J 2 Replies Last reply
    0
    • D directred

      I am using VB 2005 and have connected to an Access database. Rather than do the usual for i = 0 to total, can you populate an array with the dataset some how.

      0 Offline
      0 Offline
      0x3c0
      wrote on last edited by
      #2

      Do you want an array filled with the tables the DataSet contains? If so, and if you have included the System.Linq namespace, then you can use ds.Tables.ToArray(), where ds is your DataSet. The result of that method call will be the Tables property as an array

      1 Reply Last reply
      0
      • D directred

        I am using VB 2005 and have connected to an Access database. Rather than do the usual for i = 0 to total, can you populate an array with the dataset some how.

        J Offline
        J Offline
        Johan Hakkesteegt
        wrote on last edited by
        #3

        Or if you want to enter the values of a certain column from the dataset into the array you can use the For Each loop:

        For Each rw As DataRow In YourDataSet.Table("WhatEverTable").Rows

        Or considering that a dataset, in a sense, is a sophisticated array, you could consider forgetting about copying values to an array first, and just get them straight from the dataset.

        My advice is free, and you may get what you paid for.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups