Results 1 to 2 of 2

Thread: How to fill one dimensional array from SQL database field

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2002
    Posts
    19

    Unhappy How to fill one dimensional array from SQL database field

    Hi all
    I have a table which has numbers field,
    and I
    declared array (xarray) like

    dim xarray as integer()

    i get the resultset of my query by this query

    Dim SqlCon as new SqlConnection("Data Source=LAPTOP\ALP;User id=Sa;Password=password;Initial Catalog=loto")
    Dim SqlCmd as new SqlCommand("Select top 10 no from numbers order by date DESC",SqlCon)
    Dim SqlRdr as SqlDataReader
    SqlCon.Open()
    SqlRdr= SqlCmd.ExecuteReader()


    Now I want to fill my array with the result of this query

    Is there a way do it with out loop, If no How can I do it with loop



    Thank in advance.
    Beer

  2. #2
    Frenzied Member
    Join Date
    May 2002
    Posts
    1,602
    You just loop through your reader object

    using the

    do while myReader.Read()
    myArray(i) = myReader("CustomerID")
    i = i+1
    next

    //Henrik

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