如题:我想在通过输入一个参数,动态更新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
---------------------------请问各位高手,这是什么原因? 怎么可以解决?
在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
---------------------------请问各位高手,这是什么原因? 怎么可以解决?
解决方案 »
- 2012年6月Delphi大论坛月专家榜本人排名第三,为何没有蓝色的花花
- 请问:写软件需求文档,有没什么好用的软件?,谢谢!
- Access用SQL语句,出现charindex不能用
- 招聘高级Windows开发程序员
- 关于做一个档案管理系统的问题。。。。。。。。
- →★★★★★让你的软件一夜成名★★★★★←
- 下面是我的制作启动画面的代码,为什么Form1出来时Frm_Logo没有自动关闭?
- 请教各位大侠!关于桌面数据库后缀名为dat如何打开?
- 一个form里有多个Image 同时更新内容.....进来看吧,题目发不下
- 本来想放假之前专家分达到2000分,现在看来没什么希望了(还差352分)。我想网上也许有人象我一样,在期待着分数的突破,故散分。/踢踏
- 获取网络拨号连接列表
- OleContainer操作Word,关闭Word后不知道如何判别Word已被关闭?
所以我都搞不清楚哪里的问题了!
frxReport1.ShowReport(true);
'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;
frxReport1.LoadFromFile(WPath + '1.fr3');
加上这句试试