使用TeeChart显示数据库中的数据

问题描述 投票:0回答:1

我想使用 teechart 显示给定时间段内每日销售额的条形图,但我收到错误 不支持数据类型转换

MDB.FDQuery1.SQL.Text :=
  'SELECT DateCreated, SUM(TotalAmount) AS DailySales ' +
  'FROM SalesReceipts ' +
  'WHERE DateCreated BETWEEN :StartDate AND :EndDate ' +
  'GROUP BY DateCreated ' +
  'ORDER BY DateCreated';

// Assign the date parameters for the query
MDB.FDQuery1.ParamByName('StartDate').Value := DatePicker1.Date;
MDB.FDQuery1.ParamByName('EndDate').Value := DatePicker2.Date;

// Open the query
MDB.FDQuery1.Open;

// Bind the dataset to the chart
Series1.DataSource := MDB.FDQuery1;
Series1.XLabelsSource := 'DateCreated';
Series1.YValues.ValueSource := 'DailySales';

// Refresh the chart
DBChart1.RefreshData;
delphi teechart
1个回答
0
投票

兄弟,我认为这很可能发生,因为 SalesReceipts 表中的 DailySales 列是货币类型,但您试图将其绑定到需要数值的 Series 对象。

© www.soinside.com 2019 - 2024. All rights reserved.