PDA

Click to See Complete Forum and Search --> : Problem w/ Arrays


vb_dba
Jul 6th, 2001, 10:16 AM
When I define the array arData as below, I receive a type mismatch error when I try to assign a recordset to it using the GetRows Method: arData = RS.GetRows()

If I define the array like: Dim arData, I get a "Subscript out of range: aValues" error. aValues is the "arData" parameter for ShowChart. ShowChart loops through the array and retrieves all of the values and builds a bar graph, but it is having problems using an index w/ arData.

If anyone can help me out, I would appreciate it.

Public Sub CreateChart()

Dim i
Dim arData(100) 'Array For Values
Dim arLabels(100) 'Array For Labels

Set Conn = Server.CreateObject("ADODB.Connection")
With Conn
.CursorLocation = aduseclient
.CommandTimeout = 15
.Open CONN_STRING, UserID, PSWD
End With

SqlStr = ""
SqlStr = SqlStr & "svc_rec_online_BarChart "
SqlStr = SqlStr & "@Rec_From_Date='01/01/01', "
SqlStr = SqlStr & "@Rec_Thru_Date='7/03/01'"

Set RS = Conn.Execute(SqlStr)

arData = RS.GetRows(adGetRowsRest, adBookmarkFirst, "Total")
arLabels = RS.GetRows(adGetRowsRest, adBookmarkFirst, "rec_month")

Set RS = Nothing
Set Conn = Nothing

'Create Barchart
Call ShowChart(arData, arLabels, "Title", "X", "Y")

End Sub


Thanks In Advance,

Chris :(

CMangano
Jul 6th, 2001, 10:21 AM
Try doing:


Dim arData As Variant
Dim arLabels As Variant


Then when you pass GetRows into them, they will become arrays.

vb_dba
Jul 6th, 2001, 01:00 PM
That gave an error "Expected End of Statement". I was unaware that you could define variable datatypes in VBScript. Do I need to include a file into my asp page? Any other suggestions?

Chris

CiberTHuG
Jul 6th, 2001, 04:22 PM
Yes, you can't declare the variable as an array before you assign a record set to it. It is the same quirk as assigning the output of Split() to an array, can't do it.

I think that has to do with how = works.

Anyway... it smells like your problem is with the parameters you are giving the GetRows() method. I'm not familiar with the options, since I always use myArray = RS.GetRows() and leave it at that.

CMangano
Jul 6th, 2001, 04:29 PM
Sorry, I thought you were using VB, not VBScript. In VBScript all variables are variants by default. So try:


Dim arData, arLabels

arData = Rs.GetRows()
arLabels -= Rs.GetRows()