Using defined report from C#

BoskoBosko Belgrade, Serbia
edited 8:58PM in FastReport .NET
I found fast report as very usefull tool, but at the same time almost UNUSABLE!
FastReport Class Reference is also anusable, with no examples of usage, a little bit confusing, or maybe I am doing something wrong.
Like FastReport developers numbered classes they used in developing this tool, like they was glorifying their work, and I agree, it is great, but it is absolutelly unusable to developers!!!

I must say that I am using FastReport for the first time, and I am trying to know it better, but I lost few days, and I can't afford any more days to lose.

This is the problem:

I am trying to build invoice report.

I am trying to call the MSSQL StoredProcedure for filling data in report. It seems OK when I'm using it in designer, I am able to generate report.

But I didn't find the way to SEND PARAMETER TO REPORT FROM MY APPLICATION, in order to dinamically build SQL Query for filling data!

For example:
I have a StoredProcedure in my Database that my application is using, for example "doc_FillDocumentData". The stored procedure exepts parameter "@DocumentID";.

I was able to build it "static", in FastReport Demo program, and now I am trying to use it in my application, and to send that "@DocumentID"; parameter to report in order to build SQL Query dynamically, but I just cant find the way of doing this.

Another problem is that I am getting error message "Data source is not initialized yet". OK, the message is clear, but can anybody tell me WHERE SHOULD I INITIALIZE DATASOURCE.

Then again, I was trying to do the simpliest thing ever:
From C# code I filled DataSet, then I called Report1.RegisterData(myDataSet,"MyDataSouceName").
I was trying to set some TextField Text property from that datasource I sent.

OnBeforePrint Event of that Text Field I was trying to set something like this:
Text1.Text = myDataSource.Rows[0].Columns[0].Value.ToString()
BUT NO WAY I COULD DO THIS, althougt I thought that this was the "logical" order of objects inside datasource, obviously in FastReport .NET it IS NOT.

Maybe FastReport .NET should be named "FastReport .NOT"!

I beleive there is some "simple" way of doing this, just I didn't found an example anywhere.

Can anybody post some simple example of how it should be done in FastReport (.frx file) and in C# code?

Any example of Fast Report Class usage would be usefull.

If anybody "demistifies" me FastReport simple usage, I am bying it at once! [img]style_emoticons/<#EMO_DIR#>/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> Thanks in advance, and sorry for my language...[/img]

Comments

  • edited 8:58PM
    Hello,

    Don't judge so harshly. As you can see, the FastReport.Net is in beta stage now and the only documentation available is a class reference. At this time we working on other documents:
    - user manual;
    - programmer manual.

    Ok, let's answer your qestions line-by-line...
    wrote:
    FastReport Class Reference is also anusable, with no examples of usage

    The reference is full of examples. Don't expect the MSDN quality, but all necessary information is there. To start, open a topic for the "Report" class.
    wrote:
    But I didn't find the way to SEND PARAMETER TO REPORT FROM MY APPLICATION, in order to dinamically build SQL Query for filling data!

    For example:
    I have a StoredProcedure in my Database that my application is using, for example "doc_FillDocumentData". The stored procedure exepts parameter "@DocumentID";.

    I was able to build it "static", in FastReport Demo program, and now I am trying to use it in my application, and to send that "@DocumentID"; parameter to report in order to build SQL Query dynamically, but I just cant find the way of doing this.

    There are two ways of doing this. The right way is to define a report parameter. You can do this in the "Data" window. Press "Actions" button in it and select "New parameter...". It's not an SQL parameter; it's a parameter that can be set from your application.
    Once you have defined the parameter, you can use it everythere in the report. In your case, you have to use it to pass a value to the SQL parameter. To do this, open the "Data" window, select your datasource and click "Edit". Go "Parameters", select the SQL parameter and put your report parameter to the "Expression" property (so it will look like [myReportParam]).
    To pass a value to the report parameter from your application, use the following code:

    report1.SetParameterValue("myReportParam", 10);

    The other way is to find a datasource object and set its parameter from a code:

    TableDataSource ds = report.GetDataSource("My DataSource Name") as TableDataSource;
    ds.Parameters[0].Value = 10;

    This way is not good because you hardcode the report object's name.
    wrote:
    Another problem is that I am getting error message "Data source is not initialized yet". OK, the message is clear, but can anybody tell me WHERE SHOULD I INITIALIZE DATASOURCE.

    Looks like you are trying to print some data column in the report title band, right? But at this moment the data source (which is normally connected to the Data band) is not initialized yet. What you want to print? the first data row, the last or something else?
    wrote:
    Then again, I was trying to do the simpliest thing ever:
    From C# code I filled DataSet, then I called Report1.RegisterData(myDataSet,"MyDataSouceName").
    I was trying to set some TextField Text property from that datasource I sent.

    OnBeforePrint Event of that Text Field I was trying to set something like this:
    Text1.Text = myDataSource.Rows[0].Columns[0].Value.ToString()

    Why are you doing this? I don't get it, sorry...
    Once you have registered your DataSet in FastReport, you able to use any of its datatables in the report. To do this, go "Data|Choose Report Data..." menu and check items that you need in your report. Now you see the data you have selected, in the "Data" window. Just drag&drop from this window to your report; it will create a "Text" object with the data column inside. No need to code anything; it's a mouse-only operation.
    wrote:
    If anybody "demistifies" me FastReport simple usage, I am bying it at once!
    As you can see, you cannot do it now - it's a beta >
  • BoskoBosko Belgrade, Serbia
    edited 8:58PM
    Alex, THANK YOU!

    Now we are heading in right direction.

    I did what you said, and it worked just fine!
    wrote:
    report1.SetParameterValue("myReportParam", 10);
    That worked in all SqlQueries I need in my report.

    OK, now, let's move forward:
    wrote:
    wrote:
    Another problem is that I am getting error message "Data source is not initialized yet". OK, the message is clear, but can anybody tell me WHERE SHOULD I INITIALIZE DATASOURCE.

    Looks like you are trying to print some data column in the report title band, right? But at this moment the data source (which is normally connected to the Data band) is not initialized yet. What you want to print? the first data row, the last or something else?

    I am trying at this moment to create an invoice report.

    To make it look as it should I must have theese "lines":

    - My company name and data
    - Client's company name and data
    - List of articles
    - Totals of articles prices


    I thougt that I could print My company data in report title, client's company name and data in some band after title (for example PageHeader, and let it print on FirstPage only),
    then, in DATA BAND I should put articles, etc...

    But I am getting that error?!?
    But, when I put anything in Data Band, it is working well.
    What am I missing?
    Or maybe Report Title must be fixed, not binded to datasource?

    If I want to use all of these datas in my report dinamically, do I have to use Data Band always, to forget about ReportTitle Band?
    I don't have problem with using only DataBands in my reports, but I want to be sure if that is correct.


    And another question before I continue exploring FastReport!
    I need to be able to change SQL Server Connection in my report dinamically.
    I founded this:
    report1.Dictionary.Connections[0].ConnectionString = 'myConnectionStringGoesHere'
    Is this the correct way of changing Connection's properties in a report?

    That is all for now, but expect me back very soon! [img]style_emoticons/<#EMO_DIR#>/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> P.S.: I didn't ment to overreact and judge your tool. If I thought it is not good enough, I wouldn't waste my time trying to make it work, I just needed somebody to set me in the right direction. There is no chance that I would figure it out by my self that the answer for my problem with the parameter is "EXPRESSION" property![/img][img]style_emoticons/<#EMO_DIR#>/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> Thanks again, and I hope you will sell me your beta project, because I need an operating version of my software within a month.[/img]>
  • edited 8:58PM
    Bosko wrote: »
    I am trying at this moment to create an invoice report.

    To make it look as it should I must have theese "lines":
    - My company name and data
    - Client's company name and data
    - List of articles
    - Totals of articles prices

    I thougt that I could print My company data in report title, client's company name and data in some band after title (for example PageHeader, and let it print on FirstPage only),
    then, in DATA BAND I should put articles, etc...

    I have few questions.
    Where did you store the "my company name and data"? Is it in datasource (the first row of a datasource?), or you pass it using report parameters?
    The same for client's data. I'm sure you store it in the datasource (something like "Customers" table), but how do you select a current client for an invoice?
    Please clarify these moments and I will suggest what to do.

    Bosko wrote: »
    And another question before I continue exploring FastReport!
    I need to be able to change SQL Server Connection in my report dinamically.
    I founded this:
    report1.Dictionary.Connections[0].ConnectionString = 'myConnectionStringGoesHere'
    Is this the correct way of changing Connection's properties in a report?

    That's right at this moment, but not good. So I've added the "ConnectionStringExpression" property which you may use the way I've described above. Create a report parameter of string type, put its name rounded by brackets into this property and use report.SetParameterValue to pass your connection string. This property will be available in the tomorrow's build.
  • BoskoBosko Belgrade, Serbia
    edited 8:58PM
    wrote:
    I have few questions.
    Where did you store the "my company name and data"? Is it in datasource (the first row of a datasource?), or you pass it using report parameters?
    The same for client's data. I'm sure you store it in the datasource (something like "Customers" table), but how do you select a current client for an invoice?
    Please clarify these moments and I will suggest what to do.

    Everything is stored in a database.
    I have a table where I store company data.
    Invoice is stored in two tables: "InvoiceHead" and "InvoiceData".
    InvoiceHead holds something like the "title" of the invoice (clients data, invoice number, invoice date,...), and InvoiceData table holds articles that have been sold.

    I played around and I managed to put picture (company logo) and basic company data in TextField in a report using:
    // Company logo
    FastReport.PictureObject mypic = report1.FindObject("Picture1") as PictureObject;
    mypic.Image = myCompanyLogo;
    
    // Company data
    FastReport.TextObject myText = (FastReport.TextObject)report1.FindObject("Text1");
    myText.Text = "myCompanyDataGoesHere";
    

    Si, if I try to make it simpier as I can I would do this:
    I can se MY COMPANY DATA with ImageObject and TextObject as I mentioned above. I can pass thet either my application, or I can select it from report.

    Then, I can create ReportParameter named "DocumentID".
    With that parameter i am able to get InvoiceHead and InvloiceData rows from my tables (those two tables are referenced via "DocumentID" column in InvoiceHead table, which is the PrimaryKey of my table).
    So, I would select InvoiceHead table data, holding clients data, invoice number, date of invoice,...
    And in a second datasource I would select InvoiceData, holding articles (article name, price, discount,...)

    And again, I need:
    - My company name and data
    - Client's company name and data
    - List of articles
    - Totals of articles prices


    I manage to get proper report with something like:
    - using PictureObject and TextObject I can set MyCompanyData in REPORT TITLE BAND of the report
    - using first datasource I can set Client data and basic invoice data in first DATA BAND of the report
    - using second datasource (InvoiceData table), I can set articles and prices (in second DATA BAND of the report)

    At the and, i need totals of my invoice.

    And that was something I didn't manage to do, and that is my next question:
    What is the best way of using Totals in a report?

    I hope you understood me, and my idea of holding report data in datasources.

    Best regards!
  • edited 8:58PM
    Bosko wrote: »
    Everything is stored in a database.
    I have a table where I store company data.
    Invoice is stored in two tables: "InvoiceHead" and "InvoiceData".
    InvoiceHead holds something like the "title" of the invoice (clients data, invoice number, invoice date,...), and InvoiceData table holds articles that have been sold.

    So, your company data is stored in one-row table, and all you need is to print that row in the Report Title band. Am I right? In this case I will improve the FastReport a little to allow it using the first data row if you print a data in the band that is not connected to data (report title, page header etc). You will be able to just put a text/picture object on the report title band, connect it to data and print - without need of programming.
    Bosko wrote: »
    Then, I can create ReportParameter named "DocumentID".
    With that parameter i am able to get InvoiceHead and InvloiceData rows from my tables (those two tables are referenced via "DocumentID" column in InvoiceHead table, which is the PrimaryKey of my table).
    So, I would select InvoiceHead table data, holding clients data, invoice number, date of invoice,...
    And in a second datasource I would select InvoiceData, holding articles (article name, price, discount,...)

    So when you start report, it has an InvoiceHead table that contains one row, and several rows in the InvoiceData. With improvements that I've made (they will be avaiable in the tomorrow's build) you will be able to print InvoiceHead data in the report title, or page header, or anywhere else (because it contains one row). InvoiceData may be printed in the Data band. So your report template may looks like this:

    ReportTitle (your company name)
    ChildBand connected to the title (invoice head)
    DataBand (invoice data)
    Bosko wrote: »
    At the and, i need totals of my invoice.

    And that was something I didn't manage to do, and that is my next question:
    What is the best way of using Totals in a report?

    You have to define a total in the "Data" window. Press "Actions" and choose "New total...". In the total editor, you have to specify the following:

    - total name - you will use it to print total's value. Give it any descriptive name;
    - function;
    - data column or expression - the value which you want to summarize;
    - data band that will be used to calculate a total. The total will be calculated for each row of this band;
    - band that will reset the total value. It's a band where you print a total value (i.e. data footer, report summary, group footer etc). Leave it empty if you want to print running total.

    Once you have defined the total, just drag&drop it to the band where you want to print it.
  • BoskoBosko Belgrade, Serbia
    edited 8:58PM
    I am creating an Invoice report.

    I am doing it thru Report Designer.

    I am setting a parameter to use it in my SQL Stored Procedure (or SQL Query, whatewer I will use in report) @DocumentID, but every time I try to Preview my report I am getting an error

    The SQL Queriws looks something like:
    // This is simple SQL Query, returning document row from  SQL View inside my database
    SELECT Column1, Column2, Column3 FROM myInvoiceViewInMyDatabase WHERE DocumentID = @DocumentID
    
    // This is stored procedure that expects parameter @DocumentID, and that procedure will return articles in my document with names, prices, etc...
    EXEC doc_DocumentDataProcedure @DocumentID
    
    I set default value for that parameter, so that I can see some real data in preview.

    And every time I try to preview report, I am getting this error in messages window, and it won't compile:

    @DocumentID: Error CS1525: Invalid expression term '['
    @DocumentID: Error CS1002: ; expected
    @DocumentID: Error CS1002: ; expected
    @DocumentID: Error CS1525: Invalid expression term ']'

    I guess this is something to do with the parameter I am placing inside my SQL Query?

    So I must go to that DataSource I defined above, and remove Command Property EXPRESSION.

    Then the preview will work, but only for that time.


    Untill I try again, the "Expression" property is set again with value "[DocumentID]", and I keep getting that error.

    My idea was this:
    I was trying to build entire report in designer, preview it with the default value for @DocumentID parameter, and then, when I finish building it, I wanted to pass that parameter from my application.

    What am I doing wrong?

    I hope you understood me! >
  • BoskoBosko Belgrade, Serbia
    edited 8:58PM
    Another question regarding Date Type in report.

    How can I set the display format of a Date Column from my DataSource?

    For example: I would like it to be: 12.10.2008., database is returning 12.10.2008 00:00:00.

    How can I do this without converting it to VaRCHAR in database view?
  • edited 8:58PM
    Bosko wrote: »
    And every time I try to preview report, I am getting this error in messages window, and it won't compile:

    @DocumentID: Error CS1525: Invalid expression term '['
    @DocumentID: Error CS1002: ; expected
    @DocumentID: Error CS1002: ; expected
    @DocumentID: Error CS1525: Invalid expression term ']'

    What am I doing wrong?

    You have to create the report parameter manually in order to use it in expressions. This is recommended way. Once you have created a parameter, you may construct expressions visually in the expression editor. In your case, you did not do it; instead, you pass a parameter's value using the report.SetParameterValue. That will create the parameter too (if it is not exists); but there are some side effects.

    While posting this I've found two minor bugs in my code; so wait for midnight to try the updated version.
  • edited 8:58PM
    Bosko wrote: »
    Another question regarding Date Type in report.

    How can I set the display format of a Date Column from my DataSource?

    For example: I would like it to be: 12.10.2008., database is returning 12.10.2008 00:00:00.

    How can I do this without converting it to VaRCHAR in database view?

    Right-click the "Text" object that you use to print date. Select the "Format data..." menu item and setup the format.
  • BoskoBosko Belgrade, Serbia
    edited 8:58PM
    AlexTZ wrote: »
    AlexTZ wrote: »
    And every time I try to preview report, I am getting this error in messages window, and it won't compile:

    @DocumentID: Error CS1525: Invalid expression term '['
    @DocumentID: Error CS1002: ; expected
    @DocumentID: Error CS1002: ; expected
    @DocumentID: Error CS1525: Invalid expression term ']'

    What am I doing wrong?

    You have to create the report parameter manually in order to use it in expressions. This is recommended way. Once you have created a parameter, you may construct expressions visually in the expression editor. In your case, you did not do it; instead, you pass a parameter's value using the report.SetParameterValue. That will create the parameter too (if it is not exists); but there are some side effects.

    While posting this I've found two minor bugs in my code; so wait for midnight to try the updated version.

    Just to comment your reply before you build new download version:

    I didn't get error with my application.
    I figured out that passing parameter from my application will work, and there is no problem.
    I was getting this error in designer!

    This is my point of view, if I understood correctly your idea:
    I have a parameter I will use, and I am going to pass it from my application. That is clear.
    I thought that I can use Fast Report designer to test my report, and I figured out that, if I didn't set that parameter from my application, ofcourse, it does not exists.
    But what is use of that property "DefaultValue" of the parameter, if not to set Default parameter value if it is not set thru application and passed that way?

    I thought that should work that way...
    While I'm testing and desingning my report, it should use "DEFAULT VALUE" for generating?
    Am I right? Or the point of DefaultValue is something completelly different?

    By the way, when I put a PictureObject on a report, and I try to choose pircture from PictureObject Properties Window (Object Explorer), I am getting error: "Object reference not set to an instance of an object."

    this is not a problem for me, anyway, I am going to use picture from database or I am going to set them in my application, just for you to know...

    Thank you for your replies!
  • edited 8:58PM
    wrote:
    I didn't get error with my application.
    I figured out that passing parameter from my application will work, and there is no problem.
    I was getting this error in designer!

    That's the side effect I was talking about. You call report.SetParameterValue method once before you run the designer. But, when you press "Preview" button in the designer, the following will happen:

    - report is saved to temp stream;
    - report is prepared and previewed;
    - report is restored from temp stream. At this moment it loses all settings you made with SetParameterValue.

    Temp stream is needed because during report generation something may changed (if you use report script, for example, you may add or remove report objects, change its properties etc).
    To eliminate such effect, you may set the parameter's value in the report.StartReport event handler. It is called every time the report is started.
    wrote:
    While I'm testing and desingning my report, it should use "DEFAULT VALUE" for generating?
    Am I right? Or the point of DefaultValue is something completelly different?

    I've fixed the code so if you don't pass a value to the parameter it will use the default value.
    wrote:
    By the way, when I put a PictureObject on a report, and I try to choose pircture from PictureObject Properties Window (Object Explorer), I am getting error: "Object reference not set to an instance of an object."

    I'm not able to reproduce this; could you describe step-by-step how to get this error?
  • BoskoBosko Belgrade, Serbia
    edited 8:58PM
    AlexTZ wrote: »
    I'm not able to reproduce this; could you describe step-by-step how to get this error?

    Hm, this is problem I can't solv by my self...

    When I try to choose Image on a New / Blank report everything is working just fine when I work on some report with your Demo Program.
    Even if I load that report I am working on (Invoice.frx) in your Demo, it works with image as well.

    But when I try to choose image from my application project, where I have added Report on a form, and I opened that invoice.frx file with "right-click | Desing report" from my C# project, it reports that error when I try to load image.

    I am using Visual C# 2008 Express Edition, I put a Report on a form, and I am designing it from there.

    Even if I open a new report, it's still reporting that error. But only if I use it in C# 2008 Express.

    Maybe Visual C# 2008 Express is the problem?

  • BoskoBosko Belgrade, Serbia
    edited October 2008
    Alex,

    I did what you said, I downloaded latest build and it works really fine.

    All improvements are there for sure! [img]style_emoticons/<#EMO_DIR#>/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> Title and Footer Band now can receive DataSource values, and it is great. Everything is going the right way, but I still have a few minor problems.[/img]1.
    I have a problem with CalculatedColumns! >

    Everytime I try to multiply or devide any value I'm getting zero as a result. (?!?)
    This is the problem:
    I have three columns I need to calculate:
    Quantity, Price and Tax.
    All of these values in a report are correct, I am printing these columns separatelly, and everything looks OK.
    This TAX column comes from a database in value of 18 or 8 ( data type is decimal, or money, or double, what ever...). This values represents percents for tax.
    I need to have something like Tax Total. That means that I have Quantity, Price, and a Tax value that represent percents for Article Tax.
    I tried multiplying ((Price/100)*TaxColumn) (something like that), but every time I am getting zero for the result!

    When I put fixed value for multiplying od deviding (like (decimal)0.18 which represents 18% of tax), it works fine, I get the correct result.
    Then I thought it is maybe something with converting values to proper datatypes.
    And I tried everything that comes to my mind: Convert.ToDecimal([Articles.Tax]), I tried explicit cast like (decimal)[Articles.Tax], but every time I am getting zero.

    Interesting is, I use that same TaxColumn in my report for printing, and it prints its value correctly, but anytime I try to multiply or devide it, it is a deadend! [img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> Please, help me with this, what am i doing wrong? this should be simple operation in a report.[/img]Totals works just fine, but CalculatedColumns gave me a bit of headake! >2.
    I still have that problem with Expression property and setting a parameter in desing mode. [img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> I'm still not able to preview a report when I set that Parameter we mention before. These are parameter properties: Name=@DocumentID DataType=Int32 Expression=DocumentID It seems there is a problem with that Expression property of the parameter. I am aware that it must be set in order report to work, but it is not working for preview.[/img][img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> Anyway, when I set thet property like this: Expression=[DocumentID][/img](NOTE THE BRACKETS)
    I'm getting error we mentioned in our posts before
    wrote:
    @DocumentID: Error CS1525: Invalid expression term '['
    @DocumentID: Error CS1002: ; expected
    @DocumentID: Error CS1002: ; expected
    @DocumentID: Error CS1525: Invalid expression term ']'

    When I get rid of those brackets ( Expression=DocumentID ), I am getting following error:
    wrote:
    @DocumentID: Error CS0103: The name 'DocumentID' does not exists in the current context

    Either using the brackets or not, the report is working EXCELENT from my application!
    Parameter is passed correctly, and the report is generated correctly.

    I don't have any idea what is causing this, but maybe you would know.
    I can create (desing) a report without that Parameter, and when I finish designing it, I would add that parameter to use it with my application.
    But I think this is not the solution.

    I added the report to my application, both, the design and preview works just fine, regarding of that problem with Calculated Columns.

    I will play around with your tool, and all you have to do for now, is SEND ME THE BILL AND THE REGISTRED DLLs! [img]style_emoticons/<#EMO_DIR#>/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" /> Best regards, and see you soon here with new questions.[/img][img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> P.S.: What happened with that Connection propery of the report we spoke earlier? I need to set it dinamically, what is the best practice to do this? P.P.S.: Where can I find terms of use for FastReport DLLs? My applications are for comercial use, I need to know if there is some restrictions in DLL usage.[/img]
  • edited 8:58PM
    1) I was unable to reproduce it in the Demo program. Do you able to do this, or maybe you have a small test case for me?
    Remember that if you use the calculated column, you have to set correctly its DataType property. And (it's a limitation of .Net) use direct cast to decimal when you operating with decimal and float types in one expression:
    [Order Details.UnitPrice] * (decimal)[Order Details.Discount]

    2) The DocumentID parameter must be defined in a report. Just add it in the "Data" window, as I've suggested before.
    wrote:
    P.S.: What happened with that Connection propery of the report we spoke earlier? I need to set it dinamically, what is the best practice to do this?

    Now you have two options:
    - use ConnectionStringExpression property of the connection object. You may bind it to a report parameter and set that parameter from your code.
    - use EnvironmentSettings component (it is in the VS Toolbox). In the DatabaseLogin event handler you can specify own connection string. Read the doc regarding this event.
    wrote:
    P.P.S.: Where can I find terms of use for FastReport DLLs? My applications are for comercial use, I need to know if there is some restrictions in DLL usage.

    Read license.rtf file, it covers all terms. In short: you can use fastreport dlls in your production as royalty-free.
  • BoskoBosko Belgrade, Serbia
    edited October 2008
    I am obviously missing something big here!!!

    I lost 5 hours trying to multiply two numbers!!!!!????!!!

    Please, help me with this, I am out of ideas! [img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> I have a column in my DataSource that is type of Decimal (at least FastReport said so!). That value comes from my database and a value of that column is 0.18. I NEED TO MYLTIPLY IT BY 100, but I can't get it work![/img]>>[img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> I tried: (decimal)[Articles.Tax] * (decimal)100 (Should produce: 0.18*100=18) (decimal)[Articles.Tax] * (decimal)100.00 (Should produce: 0.18*100=18) Math.Round((decimal)[Artikli.PDV],2) * Math.Round((decimal)100.00,2) (Should produce: 0.18*100.00=18.00, instead of that I am getting 0.00) Convert.ToDecimal([Articles.Tax]) * Convert.ToDecimal(100) Should produce: 0.18*100.00=18.00, instead of that I am getting 0.0000) In database I tryed converting (it is Decimal(18,4) already, but anyway I tried) CONVERT(DECIMAL(18,2),Articles.Tax) to get proper decimal value from database CONVERT(MONEY,Articles.Tax) to get proper decimal value from database I am loosing my mind, or I became blind, there is no third option!!! Just to confirm: WHEN I PRINT [Articles.Tax] in FastReport I get 0.18, or 0.08,... ??????? Please!!!???!!! I am becoming hysteric here![/img]>
  • edited 8:58PM
    See the attached report. It's a modified "Complex (Master-detail with group)" sample from the Demo.exe. Run it in the Demo.exe.
  • BoskoBosko Belgrade, Serbia
    edited October 2008
    Noup! [img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> This is the data Price (decimal) = 100 Discount (decimal) = 10 When i try[/img]
    (decimal)1 - [Articles.Discount] / (decimal)100
    
    I am getting some crazy values like -0.18 (beleve it or not!), and note the minus sign!?!? [img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> I was expecting to get discount value as 0.9 to multiply the price with it and print PRICE WITH DISCOUNT, but no way![/img][img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> I was expecting this: 1.00 - 10/100.00 = 0.90 I give up! I have no more time to waste on this. I am going to calculate all values I need inside the Stored Procedure, and the report will get them ready to print, I should do this long time ago! Never mind, lats go on, I saw how it works in your templates and that one you send me "Using_Calculated_Columns.frx", it is easy as that, but maybe I am doing something wrong... I don't know... Sorry for wasteing your time as well as mine![/img]>
  • edited 8:58PM
    Every way I've tried to do this it works for me. You have tried to do this several ways and get the error. Just a mysticism!
    If you able to prepare a test application and send it to me, it would be nice.
  • BoskoBosko Belgrade, Serbia
    edited October 2008
    Alex, I apologize! [img]style_emoticons/<#EMO_DIR#>/sad.gif" style="vertical-align:middle" emoid=":(" border="0" alt="sad.gif" /> Your Calculated Columns works! There was something in that report I was creating, I didn't manage to make it calculate columns correct. When I opened new report, using same data from database, everything worked!!! I thing maybe there was something wrong with that Invoice.frx file I edited these days. Nevermind, everything is vorking just fine now, it's all that metters. I have a few new comments now.[/img]
    AlexTZ wrote: »
    AlexTZ wrote: »
    P.S.: What happened with that Connection propery of the report we spoke earlier? I need to set it dinamically, what is the best practice to do this?
    Now you have two options:
    - use ConnectionStringExpression property of the connection object. You may bind it to a report parameter and set that parameter from your code.
    - use EnvironmentSettings component (it is in the VS Toolbox). In the DatabaseLogin event handler you can specify own connection string. Read the doc regarding this event.

    I did this in that DatabaseLogin event:
    report1.Dictionary.Connections[0].ConnectionString = "Data Source=.\SQLEXPRESS;Initial Catalog=myDatabase;Integrated Security=False;Persist Security Info=True;User ID=myUsername;Password=myPassword"
    
    And I thing this worked...

    I thought (and hoped) that I could just pass SqlConnection as a reference to report, for example
    (SqlConnection) report1.Dictionary.Connections[0] = my_Previously_Created_SqlConnection;
    

    Is there a way to do that?

    I noticed something that might interest you, regarding Table desing in designer.
    When I place TableObject on some Band in report, default is 5 rows and 5 columns. When I select all columns, right click on that selected columns and select "Join Cells", desing looks OK, but inside frx file, there are still Rows and Columns in xml the from default set. U should try this.

    When I place table on a report, and from Properties window change "RowCount" and "ColumnCount" property, everything is fine, in designer as well as in Invoice.frx file.

    No big deal.

    Anyway, we are considering of buing your tool, never mind it is not finished yet, I am going to need reports very, very soon. Maybe I am going to need this in 10 days from now. [img]style_emoticons/<#EMO_DIR#>/unsure.gif" style="vertical-align:middle" emoid=":unsure:" border="0" alt="unsure.gif" /> Can we arrange something in order to buy FastReport .NET, nevermind it is still beta, we will change it as we pass along. We would like you to send us invoice for wire transfer, if it is possible? P.S.: I am testing and learning FastReport .NET, so expect me back soon with new questions![/img][img]style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Thanks in advance.[/img]
  • edited 8:58PM
    Bosko wrote: »
    I did this in that DatabaseLogin event:
    report1.Dictionary.Connections[0].ConnectionString = "Data Source=.\SQLEXPRESS;Initial Catalog=myDatabase;Integrated Security=False;Persist Security Info=True;User ID=myUsername;Password=myPassword"
    
    And I thing this worked...

    I meant this (see the doc for this event):
    private void report1_DatabaseLogin(object sender, DatabaseLoginEventArgs e)
    {
      e.Connection.ConnectionString = my_connection_string;
    }
    

    Bosko wrote: »
    I thought (and hoped) that I could just pass SqlConnection as a reference to report, for example
    (SqlConnection) report1.Dictionary.Connections[0] = my_Previously_Created_SqlConnection;
    

    Is there a way to do that?

    No, since the FastReport connection object isn't just SqlConnection. You may pass the ConnectionString only.
    Bosko wrote: »
    I noticed something that might interest you, regarding Table desing in designer.
    When I place TableObject on some Band in report, default is 5 rows and 5 columns. When I select all columns, right click on that selected columns and select "Join Cells", desing looks OK, but inside frx file, there are still Rows and Columns in xml the from default set. U should try this.

    When I place table on a report, and from Properties window change "RowCount" and "ColumnCount" property, everything is fine, in designer as well as in Invoice.frx file.

    That's right because when you join/split cells the table rows and columns do not change.
    Bosko wrote: »
    Anyway, we are considering of buing your tool, never mind it is not finished yet, I am going to need reports very, very soon. Maybe I am going to need this in 10 days from now. [img]style_emoticons/<#EMO_DIR#>/unsure.gif" style="vertical-align:middle" emoid=":unsure:" border="0" alt="unsure.gif" /> Can we arrange something in order to buy FastReport .NET, nevermind it is still beta, we will change it as we pass along. We would like you to send us invoice for wire transfer, if it is possible?[/img]

    Ok, I will contact you later this week.
  • Open Source - Documentation and examples are WOEFUL. Trying to run a simple 1 line query, preview works but calling via report.Prepare() gives QryCustomer does not exist. QryCustomer is the name I used in the report designer so dreadfully misleading error message.

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.