0

我收到以下错误:

Category:Microsoft VBScript runtime 
Description:Subscript out of range
Line:46

从以下代码:

<%
''*************************************************************************
''Created Date: 10/28/13
''Created By:   NG
''Description:  Test page for new highcharts charts replacing ChartFX for business trends
''History:      N/A
''*************************************************************************

'OPEN CONNECTION TO SQL SERVER
'-create objects
Set adoCon = Server.CreateObject("ADODB.Connection")
Set adoRsGraph = Server.CreateObject("ADODB.Recordset")
Set adoCom = Server.CreateObject("ADODB.Command")
'-open connection

'scon = "FILE NAME=" & server.MapPath("/d_support") & "\cfn_datastore_heracles.udl"
scon = "FILE NAME=" & server.MapPath("/d_support") & "\cfn_datastore.udl"

adoCon.Open sCon

adoCom.CommandType= 4
adoCom.ActiveConnection = sCon
'GET RECORDSET DATA NEEDED TO FILL IN THE ACCOUNT BALANCE CHART
'-call stored proc to retrieve data

    adoCom.CommandText="sp_Chart_AccountBalance3"
    adoCom.Parameters(1) = 21820

adoRsGraph.CursorLocation = 3
adoRsGraph.Open adoCom

dim xAxisData()
dim yAxisData()
j = 0               
    adoRsGraph.MoveFirst            
if adoRsGraph.EOF = false then

    Do Until adoRsGraph.EOF
        xAxisData(j) = adoRsGraph("Value")
        yAxisData(j) = adoRsGraph("Date")

        j = j + 1
        adoRsGraph.MoveNext
    Loop
end if
%>

我不完全确定第 46 行是什么,但我认为它必须在我通过记录集的循环中。我在运行它时已经完成了跟踪,并看到存储过程被正确调用,并且在 SQL 服务器中运行时它包含数据集中的记录,那么为什么我的循环不能为数组分配值呢?

4

1 回答 1

1

你已经创建了两个数组,但是在你给它们一个大小之前你不能使用它们。

ReDim在将值放入数组之前,使用命令调整数组的大小:

ReDim xAxisData(j)
ReDim yAxisData(j)
于 2013-10-28T20:35:51.080 回答