如题:我想在通过输入一个参数,动态更新fastreport报表中的数据,请问如何可以实现?我在project中建立了一个DataModule1和一个form1.
在DataModule1中放了一个ADOconnection1,一个ADOQuery1,一个DataSource1和一个frxDBDataset1.
其中,
ADOconnection连接SQL server;
ADOQuery1.Connection := ADOconnection1;
DataSource1.DataSet := ADOQuery1;
frxDBDataset1.frxDBDataset1 := DataSource1;在form1中放了一个Edit1和一个Button1,
我想实现在点击Button的时候,把Edit1中的内容作为参数,动态输出报表的数据.
Button1Click的代码如下:procedure TForm1.Button1Click(Sender: TObject);
var
  WPath: String;
  stationCode: String;
begin
  stationCode := self.Edit1.Text;  DataModule2.ADOQuery1.Close;
  DataModule2.ADOQuery1.SQL.Clear;
  DataModule2.ADOQuery1.SQL.Add(
    'select station_code, ip, mine_code, mine_name, address from tb_station where station_code = '''
    + stationCode + '''');
  DataModule2.ADOQuery1.Open;  WPath := ExtractFilePath(Application.ExeName);;
  frxReport1.LoadFromFile(WPath + '1.fr3');
  frxReport1.ShowReport;
end;当我第一次点击Button1的时候,报表可以根据我输入的数据,输入数据.
但当我再点击一次的时候,就会报错.错误如下:
---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EAccessViolation with message 'Access violation at address 0055425D in module 'Project1.exe'. Read of address 6C4120F6'. Process stopped. Use Step or Run to continue.
---------------------------
OK   Help   
---------------------------请问各位高手,这是什么原因? 怎么可以解决?

解决方案 »

  1.   

    跟踪看 是select语句不对,还是引用的文件不存在,还是其他什么的
      

  2.   

    各位大哥,我已经跟踪过了,报错的地方不是在我写的代码,而是在fastreport自带的代码里面TfrxDBDataset.IsBlobField
    所以我都搞不清楚哪里的问题了!
      

  3.   

    把这句frxReport1.ShowReport;稍微该一下试试
    frxReport1.ShowReport(true);
      

  4.   

    改下这句呢
    'select station_code, ip, mine_code, mine_name, address from tb_station where station_code = ''' + stationCode + '''''select station_code, ip, mine_code, mine_name, address from tb_station where station_code = '+#39+ stationCode +#39;
      

  5.   

      frxReport1.Clear;
      frxReport1.LoadFromFile(WPath + '1.fr3');
    加上这句试试
      

  6.   

    估计是报表哪设置的问题。 楼主的SQL语句没错。
      

  7.   

    fasterreport有自己的 dialogForm,在那里可以定义参数,感觉很不错。