A simple table (Table1) with two fields (numer of monthly Apples and number of monthy Oranges for two seasons) in SQL Server 2000. I need to extract the values of those fields using Classic ASP and populate two arrays. Constraints: those arrays were defined already by an out-of-the-shelve app that I need not to touch too much because I am a beginner in Classic ASP and I might do something wrong.
Definition of those arrays are as follows:
Dim m_arrApples, m_arrOranges
I have succeded to connect to database, extract data and then display it in a browser (format figures). Yet, when I need to transfer it in an array (in order to be taken over by that out-of-the-shelve app and process it (displaying in a graph format) I encounter an error. Here it is my code:
'Open connection with SQL Server
Dim conn
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=SQLOLEDB;server=" & NameServer & ";database=" & DataBaseName & ";uid=" & NameUser & ";pwd=" & DataBasePassword & ";"
'Open table and all records for further processing
dim strSQL
strSQL = "select * from " & Table1
Set rst = conn.Execute(strSQL)
'Going through the records in the table and try to get values of each field and allocate them to the array
If rst.BOF And rst.EOF Then
Response.Write "No data"
Else
i=0
Do While (Not rst.EOF)
i=i+1
'The line below confirms that the data extracted from database is displayed in the browser
'in its primary form (not graph), but that means I did it correctly up to this point
Response.Write rst("Apples") & "/" & rst("Oranges") & "<br>"
m_arrApples(i)= rst("Apples") ' THE ERROR IS AT THIS LINE. HERE THE SCRIPT IS STOPPED
m_arrOranges(i)= rst("Oranges")
rst.MoveNext
Loop
End If
The error is:
Microsoft VBScript runtime error '800a000d'
Type mismatch
Any hint will be highly appreciated.