Results 1 to 3 of 3

Thread: [RESOLVED] [VB6 RC6 SQLite] Need clarification on .ValueMatrix

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2010
    Posts
    1,245

    Resolved [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.

    Name:  2023-09-27_20-01-27.png
Views: 79
Size:  5.1 KB

    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

  2. #2
    Fanatic Member VanGoghGaming's Avatar
    Join Date
    Jan 2020
    Location
    Eve Online - Mining, Missions & Market Trading!
    Posts
    981

    Wink Re: [VB6 RC6 SQLite] Need clarification on .ValueMatrix

    Quote Originally Posted by webbiz View Post
    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

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2010
    Posts
    1,245

    Re: [VB6 RC6 SQLite] Need clarification on .ValueMatrix

    Quote Originally Posted by VanGoghGaming View Post
    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
  •  



Click Here to Expand Forum to Full Width