I am don’t know what I have that is wrong… I am trying to create a chart from a recordset. The recordset does have data:
MariaDB [va_1]> select date, sum(credit) as tTot, GL_Account from transactions where gl_account LIKE ‘4%’ group by extract(year from date) desc;
±-----------±------------±-----------+
| date | tTot | GL_Account |
±-----------±------------±-----------+
| 2023-01-11 | 38463.6600 | 410000 |
| 2022-01-06 | 155758.4998 | 410000 |
| 2021-10-07 | 88311.5598 | 410000 |
| 2020-11-30 | 86476.4804 | 430000 |
| 2019-12-01 | 68791.2707 | 430000 |
±-----------±------------±-----------+
5 rows in set (0.010 sec)
but my code crashes each time I try to input those values into an array for the chart to use:
if Session.SelCompany.Connect then
var rsttCompany as recordset = Session.SelCompany.SQLSelect("Select * from company")
Session.fyend=rsttCompany.Field("fy_month").Value
VAR tYearEnd as integer = Session.fyend
Dim rstSales as Recordset = session.SelCompany.SqlSelect("select date, sum(credit) as tTot, GL_Account from transactions where gl_account LIKE '4%' group by extract(year from date) desc;")
Var tARYear, tINVYear as Date
While not rstSales.EOF
Var x as Single = 0
For x=0 to 4
tARYear=rstSales.Field("date").DateValue
arYear(x)=tARYear.Year
ARTot(x)=rstSales.Field("tTot").Value
rstSales.MoveNext
Next x
Exit While
Wend
Var ds1 as new WebChartLinearDataset("AR Amount",color.Red, true, ARTot)
Var ds2 as new WebChartLinearDataset("Year",color.Red, true, arYear)
ds1.ChartType = WebChartLinearDataset.ChartTypes.Bar
ds2.ChartType = WebChartLinearDataset.ChartTypes.Bar
Chart1.AddDatasets(ds1,ds2)
End If