Changing frxDBDataset
I seem to be having a problem loading a different reports with different dataset using the same frxDBDataset component. The problem is when I setup a report with a data set and then try to change to a different report with a different dataset the original data set still exsists.
Using mysql data components.
myquery.sql.text:='SELECT * FROM CLIENTS'
myquery.open;
frxDBDataset1.datasource:=mydatasource;
frxReport1.loadfromfile('c:\reports\clientlist.fr3');
frxReport1.preparereport();
(Then if I try to perform another report....)
myquery.close;
myquery.sql.text:='SELECT * FROM VENDORS
myquery.open;
frxDBDataset1.datasource:=mydatasource;
frxReport1.loadfromfile('c:\reports\vendorlist.fr3');
frxReport.preparereport();
This dataset is from the original query, and I get errors that some fields do not exist. Which is correct, since the data set is from the first query.
What do I need to change for the new data set to be loaded into the report? I have tried many diffent ways, but just can seem to get it to work.
Can the report change to a different dataset, or do I have to setup a new dataset component for each query?
Using mysql data components.
myquery.sql.text:='SELECT * FROM CLIENTS'
myquery.open;
frxDBDataset1.datasource:=mydatasource;
frxReport1.loadfromfile('c:\reports\clientlist.fr3');
frxReport1.preparereport();
(Then if I try to perform another report....)
myquery.close;
myquery.sql.text:='SELECT * FROM VENDORS
myquery.open;
frxDBDataset1.datasource:=mydatasource;
frxReport1.loadfromfile('c:\reports\vendorlist.fr3');
frxReport.preparereport();
This dataset is from the original query, and I get errors that some fields do not exist. Which is correct, since the data set is from the first query.
What do I need to change for the new data set to be loaded into the report? I have tried many diffent ways, but just can seem to get it to work.
Can the report change to a different dataset, or do I have to setup a new dataset component for each query?
Comments
**Had to add a few more lines of code to get it to work. If any other methods please reply.
(Then if I try to perform another report....)
myquery.close;
myquery.sql.text:='SELECT * FROM VENDORS
myquery.open;
frxReport.clear;
frxDBDataset1.datasource:=mydatasource;
frxReport.DataSet.add(frxDBDataset1);
frxReport1.loadfromfile('c:\reports\vendorlist.fr3');
frxReport.preparereport();
also you should pay attention to the prop settings of the datasets such as open and close dataset
if you are manipulating them in your code.