Results 1 to 4 of 4

Thread: storing Information to an array

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Ca
    Posts
    106

    Question

    I'm currently making a program that reads the data from SQL server. Once I get connected to the server, I have to store all the informations from the database to an array.

    Set m_oconn = CreateObject("adodb.connection")
    m_oconn.open "sql"
    sql = "SELECT top 100000 * FROM [masterdisc2000_email]"
    Set l_ors = m_oconn.execute(sql)

    dim storeinfo as variant
    storeinfo = l_ors

    After I do these statements, if I try to get single info in storeinfo, for example, storeinfo(5), error message comes out stating that the content is out of range. There are only one field in masterdisc2000 which contains email address. Help needed ASAP...

    Another question... is creating a recordset and running a loop after faster or storing the info into an array after reading the info from the server and then running a loop with an array faster?

    [Edited by xstopx81 on 08-02-2000 at 02:01 PM]

  2. #2
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105
    How many table elements (fields) are there in masterdisc2000_email?


  3. #3
    Lively Member
    Join Date
    Jul 2000
    Posts
    104
    Maybe...

    Code:
    'Create the Recordset object
    'Declare the array
    Dim storinfo() As String
    Dim i As Integer
    
    yourRecordset.MoveFirst
    
    For i = 0 to yourRecordset.Count
        ReDim Preserve storeinfo(i) = yourRecordset.Fields!Email_Address
        i = i + 1
        yourRecordset.MoveNext
    Next i

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Ca
    Posts
    106

    Exclamation

    I have figured it out with MSDN Help and I though maybe someone might make a use of it. The problem with GetRows function is that it returns two-dimentional array. Here are the codes that I used to get it work.

    dim temp as variant
    'link to SQL server
    '
    '
    'if desired, you can get selected amount of rows
    'using getrows(number of desired rows)
    temp = myRecordset.GetRows(1)
    'if you want to copy this two dimentional array into a
    'single array..
    static oneDarray(1 to 1000) as integer
    for i = 1 to 1000
    oneDarray(i - 1) = temp(0, i - 1)
    next
    'Now the info is stored in oneDarray


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