VBScript create a multi-dimensional array and add to it?

后端 未结 3 1696
一整个雨季
一整个雨季 2021-01-13 15:55

This is a doozy for me haha, I\'ve pretty much checked nearly every page on Google Search and I still don\'t quiet understand how to do it.

I want to create a multi

3条回答
  •  执笔经年
    2021-01-13 16:13

    This may be off-topic, but after seeing your exact code, why aren't you using the built-in ADO function: GetRows() ?

        sub grabdata
            SQL_query = "SELECT * FROM MSAccess_table"
            Set rsData = conn.Execute(SQL_query)
            If Not rsData.EOF Then aData = rsData.GetRows()         
        end sub
    

    This returns all your column # as the first index, and the rows (data) in the second.

    So to loop through it, you would:

    If IsArray(aData) Then
        For x = lBound(aData,2) to uBound(aData,2) 'loops through the rows
            Col1 = aData(0,x)
            Col2 = aData(1,x)
            Col3 = aData(2,x)
            Response.Write "Row #" & x+1 & "
    " Response.Write "This is the data in Column1: " & Col1 & "
    " Response.Write "This is the data in Column2: " & Col2 & "
    " Response.Write "This is the data in Column3: " & Col3 & "
    " Next End If

    *NOTE: Rows (and columns) start on 0 in the array by default.

提交回复
热议问题