|
-
Aug 2nd, 2000, 12:48 PM
#1
Thread Starter
Lively Member
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]
-
Aug 2nd, 2000, 12:52 PM
#2
Frenzied Member
How many table elements (fields) are there in masterdisc2000_email?
-
Aug 2nd, 2000, 01:27 PM
#3
Lively Member
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
-
Aug 2nd, 2000, 02:55 PM
#4
Thread Starter
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|