将ADO访问Access数据库返回的记录集中的数据赋给数组的问题,帮帮忙啊
把ADO对象连接数据库,把符合查询条件的纪录集中数据赋给二维数组,我只知道数据的字段数,不知道记录数,我就定义了一个动态数组,运行提示我下标出界,问题出在哪呢,数据库已连接,代码如下
varSource = "select * from TireData where TireManufacturer= ' " & var1 & " ' and TestDate= ' " & var7 & " ' and TestState= '纯侧偏 ' "
rs2.CursorLocation = adUseClient
rs2.Open varSource, cnn, 3, 3 'cnn为连接字符串
Dim rc As Integer
rc = rs2.RecordCount
Dim lateral() As Double
rs2.MoveFirst
Dim i As Integer
For i = 1 To rc
lateral(i, 1) = rs2.Fields(10)
lateral(i, 2) = rs2.Fields(11)
lateral(i, 3) = rs2.Fields(12)
lateral(i, 4) = rs2.Fields(13)
lateral(i, 5) = rs2.Fields(14)
lateral(i, 6) = rs2.Fields(15)
lateral(i, 7) = rs2.Fields(16)
lateral(i, 8) = rs2.Fields(17)
lateral(i, 9) = rs2.Fields(18)
lateral(i, 10) = rs2.Fields(19)
lateral(i, 11) = rs2.Fields(20)
rs2.MoveNext
Next
[解决办法]
Dim lateral() As Double
redim lateral(1 to 11,0 to rs2.recordcount)
lateral(i, 1) = rs2.Fields(10) ==〉 lateral( 1,i) = rs2.Fields(10)
然后写出来就好了