-
Sep 27th, 2023, 08:16 PM
#1
Thread Starter
Frenzied Member
[RESOLVED] [VB6 RC6 SQLite] Need clarification on .ValueMatrix
I ran the following code...
Code:
Private Sub Form_Load()
Dim Rs As cRecordset
Dim SQL As String
SQL = "SELECT Portfolio FROM Charts"
Set Rs = Cnn.GetRs(SQL)
If Rs.RecordCount < 1 Then 'no portfolios
List1.Text = "<No Portfolios Exist>"
Else
Dim i As Long
For i = 0 To Rs.RecordCount - 1
List1.AddItem Rs.ValueMatrix(i, 0) 'get porfolio name
Next i
End If
End Sub
And this successfully pulled out the Portfolio names and placed in a List.
There are currently just two rows in this table.

When I first wrote the code, I used:
Rs.ValueMatrix(i, 1)
This failed. And this is the reason for this thread.
Looking at the data above, you have two rows. So the first parameter of .ValueMatrix(row, col) is for the row zerobasedindex. Thus, 0 for the first row, 1 for the second. Check!
But then, I see 5 columns. First column is Chart_ID, second is Portfolio, the one I want. Therefore, if col is also zerobasedindex, then Portfolio would be 1.
But it is not. It is zero.
Why is Chart_ID not zero?
TIA
-
Sep 27th, 2023, 08:29 PM
#2
Re: [VB6 RC6 SQLite] Need clarification on .ValueMatrix
 Originally Posted by webbiz
Code:
SQL = "SELECT Portfolio FROM Charts"
Your recordset only has one column, "Portfolio", so its index in the matrix is zero. You need to "SELECT" more columns or all of them with "SELECT *" if you want your recordset to show those columns.
"ValueMatrix" must be a property restricted only to RC6 recordsets but this is the classic way to loop through a traditional recordset:
Code:
With Rs
.MoveFirst
While Not .EOF
List1.AddItem .Fields(0) 'get portfolio name
.MoveNext
Wend
End With
Last edited by VanGoghGaming; Oct 13th, 2023 at 04:01 PM.
-
Sep 27th, 2023, 08:54 PM
#3
Thread Starter
Frenzied Member
Re: [VB6 RC6 SQLite] Need clarification on .ValueMatrix
 Originally Posted by VanGoghGaming
Your recordset only has one column, "Portfolio", so its index in the matrix is zero. You need to "SELECT" more columns or all of them with " SELECT *" if you want your recordset to show those columns.
"ValueMatrix" must be a property restricted only to RC6 recordsets but this is the classic way to loop through a traditional recordset:
Code:
With Rs
.MoveFirst
While Not .EOF
List1.AddItem .Fields(0) 'get portfolio name
.MoveNext
Wend
End With
Well, that was sure a brain fart if I've ever seen one.
Thanks @VanGoghGaming
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
|