Changing frxDBDataset

edited September 2009 in FastReport 4.0
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?

Comments

  • edited 11:38AM
    EricE wrote: »
    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?


    **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();

  • gordkgordk St.Catherines On. Canada.
    edited 11:38AM
    use different frxdbdatasets for each query the report definition keeps track of the active dataset(s).
    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.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.