Results 1 to 2 of 2

Thread: [2008] create an array from a column in a datagridview

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2008
    Posts
    7

    Unhappy [2008] create an array from a column in a datagridview

    hi there: im new to programming and i have the following code:

    Dim dt As New DataTable
    Dim da As New SqlClient.SqlDataAdapter("SELECT FEE_NAME, convert(varchar(50), convert(money, FEE_AMOUNT), 1) FROM FEE_TABLE ", m_Connection)
    da.Fill(dt)

    DataGridView1.DataSource = dt

    now this will show in the datagridview as:

    _______________________
    FEE_NAME ..| FEE_AMOUNT
    ---------------------------
    registration..| 8,000.00
    ---------------------------
    books..........| 4,500.00
    ---------------------------
    uniform........| 7,300.00
    ---------------------------
    library..........| 3,000.00
    ________________________
    (the dots are just so i could align them)

    is it possible to put all the rows from FEE_NAME into an array when its already in the datagridview.

    so the array will show
    array1 = ["registration" , "uniform" , "books" , "library" ]

    i have reAd that i needed to use a for each statement like:

    For Each row As DataGridViewRow In DataGridView1.Rows

    DONT KNOW WHAT TO PUT HERE.

    Next

    because i need to add the data from the array to a new table in the database or create a view. im using ms sql server 2005 as my db. a sample code will really really help me. thanks in advance.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] create an array from a column in a datagridview

    Gee, this seems sorta familiar.

    http://www.vbforums.com/showthread.php?t=547918
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

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