NO IDEA IF IS POSSIBLE fill array and retrive items...

User avatar
sal21
PlatinumLounger
Posts: 4334
Joined: 26 Apr 2010, 17:36

NO IDEA IF IS POSSIBLE fill array and retrive items...

Post by sal21 »

Code: Select all

...
Private Sub TEST_ARRAY()

    If Not (RS Is Nothing) Then
        If (RS.State And adStateOpen) = adStateOpen Then RS.Close
        Set RS = Nothing
    End If
    
    Set RS = New ADODB.Recordset
    SQL = "SELECT LICODART, LICODLIS, LIPREZZO, LISCONT1 FROM " & NOME_DBF_LISTINI & " ORDER BY LIDATATT"
    RS.Open SQL, CON, adOpenForwardOnly, adLockReadOnly
    
    NR = 0
    Do While Not RS.EOF
    DoEvents
    
    
    NR = NR + 1
    
    RS.MoveNext
    Loop

End Sub
....
pseudo code:

1)I need to fill MyArray
2) based the first element (LICODART) into my array, filter the related item based myvar=TEST, and retrieve all block of items.
3) loop the result of the filtered block

possible?

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: NO IDEA IF IS POSSIBLE fill array and retrive items...

Post by HansV »

Why not add a WHERE-clause to your SQL:

Code: Select all

    SQL = "SELECT LICODART, LICODLIS, LIPREZZO, LISCONT1 FROM " & NOME_DBF_LISTINI & _
        " WHERE LICODART='" & myvar & "' ORDER BY LIDATATT"
You can then loop through the recordset, or read the entire recordset into an array using RS.GetRows.
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4334
Joined: 26 Apr 2010, 17:36

Re: NO IDEA IF IS POSSIBLE fill array and retrive items...

Post by sal21 »

HansV wrote:
03 Nov 2022, 19:51
Why not add a WHERE-clause to your SQL:

Code: Select all

    SQL = "SELECT LICODART, LICODLIS, LIPREZZO, LISCONT1 FROM " & NOME_DBF_LISTINI & _
        " WHERE LICODART='" & myvar & "' ORDER BY LIDATATT"
You can then loop through the recordset, or read the entire recordset into an array using RS.GetRows.
1)no where clausole i need to have all recordet.
2)yes i need to loop througt all recordset
3) i need to fill an array, with the filter, to extract the block

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: NO IDEA IF IS POSSIBLE fill array and retrive items...

Post by HansV »

Why do you need the entire recordset if you're going to filter it anyway?
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4334
Joined: 26 Apr 2010, 17:36

Re: NO IDEA IF IS POSSIBLE fill array and retrive items...

Post by sal21 »

HansV wrote:
03 Nov 2022, 20:11
Why do you need the entire recordset if you're going to filter it anyway?
i need to use array in other part of my project.

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: NO IDEA IF IS POSSIBLE fill array and retrive items...

Post by HansV »

Ok, then open the recordset with the WHERE clause and use GETROWS to populate the array, then open the recordset again without the WHERE clause to loop through all records.
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4334
Joined: 26 Apr 2010, 17:36

Re: NO IDEA IF IS POSSIBLE fill array and retrive items...

Post by sal21 »

HansV wrote:
03 Nov 2022, 20:23
Ok, then open the recordset with the WHERE clause and use GETROWS to populate the array, then open the recordset again without the WHERE clause to loop through all records.
????

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: NO IDEA IF IS POSSIBLE fill array and retrive items...

Post by HansV »

What don't you understand in my reply?
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4334
Joined: 26 Apr 2010, 17:36

Re: NO IDEA IF IS POSSIBLE fill array and retrive items...

Post by sal21 »

HansV wrote:
03 Nov 2022, 20:55
What don't you understand in my reply?
First big problem gettow go in error...
my recoedcount is 2.967.335!

User avatar
HansV
Administrator
Posts: 78236
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: NO IDEA IF IS POSSIBLE fill array and retrive items...

Post by HansV »

Wow! in that case. looping through all records isn't going to work either - it would take far too long!

You'll have to restrict the number of records that you want to retrieve.
Best wishes,
Hans