Loading Array from Dataset


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7

Thread: Loading Array from Dataset

  1. #1
    Join Date
    Jul 2004
    Posts
    365

    Question Loading Array from Dataset

    I'm tyring to load an array from a dataset. There are 10 records in the dataset. What I'm doing is setting a datarow and looping through this dataset and trying to add each row to an array. Not sure how to do this?

    Also, If I wanted to skip the array all together, when I loop through the dataset how do I add each row individually to another dataset?

    thanks for the help

    jb

  2. #2
    Join Date
    Nov 2006
    Posts
    13
    It all depends on what format your data set is in. If your dataset is going to be varying in elements, all you have to do is:


    Code:
    dim myArr()
    
    y=0
    For Each item In DataSet
      ReDim Preserve myArr(y)
      myArr(y) = item
      y=y+1
    Next

  3. #3
    Join Date
    Jul 2004
    Posts
    365
    My dataset has 3 fields in it, all are strings, 10 records total. I would like each element in the array to be a row from the dataset. Is this possible?

  4. #4
    Join Date
    Nov 2006
    Posts
    13
    but where is your data stored??? are we talking database, flat file, etc. if it's a database, dumping the information into the array will depend on your query. if it's a flat file, it will depend on how the information is presented on each line.

  5. #5
    Join Date
    Jul 2004
    Posts
    365
    Sorry.. It's coming from a sql server database. I have the array loaded with the data, when I do a datagridview.datasource = arrayname it just puts the lenght of each element in the first column.

  6. #6
    Join Date
    Nov 2006
    Posts
    13
    can you post the snippet of code dealing with the problem pls.

  7. #7
    Join Date
    Jul 2004
    Posts
    365
    Thanks for the help. I figured out. I had to create my columns programmatically then create my array then add it to the grid. Sorry for the frustration..

Similar Threads

  1. Loading Dataset from Stored Proc.
    By jcb1269 in forum .NET
    Replies: 1
    Last Post: 10-17-2006, 02:42 PM
  2. Replies: 1
    Last Post: 01-12-2006, 06:53 PM
  3. Loading XML data into DataSet w/ different schema
    By Michael Koehmstedt in forum XML
    Replies: 1
    Last Post: 11-07-2002, 08:05 PM
  4. Replies: 1
    Last Post: 03-03-2002, 10:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center