Combine two datasets in one Crystal Report - c#

I want to create a type of Summary report for an account. The report should have a chart of account data from one data source AND a grid of different account data from another data source.
I want to use all of the data from table one where account_ID = X AND I want to use all of the data from table two where account_ID = x.
Crystal Reports will let me add two different datasources, but It wants to link them to create a sub report in a Master / Details kind of way. I need to report on ALL of the data in table one, and all of the data in table two.
I'm a bit confused on how to do that.
Note: When I'm doing this for one report only, I just create a datatable from a view filtered by the account_ID and then set that as the datasource for the report. That way the heavy lifting is done before Crystal Reports gets the data. Again, not sure how to do that for two different datasources.

If the datasets are different enough that a JOIN doesn't make sense, you'll want to use a sub-report. First, create the report as if you were only using one of the data sets. Then, insert a sub-report where you want the second grid to show up (go to Insert --> Subreport); usually putting it in a new section. Build the sub-report using only the second dataset -- it may help to think of it as a full report in itself, as if the main report didn't exist.
Right-click the sub-report "field" in the main report and select Change Subreport Links. Add the account_ID field and you'll automatically get a parameter, Pm-Table.account-ID, and basic select expert in the sub-report itself.
Double-click it, and you'll get a new tab for just the sub-report. In the long run, you'll want most of the sections suppressed, so the output is just the grid.
Once all that is done, running the main report will display both sets of results.

Related

How can I add unknow Table as source for XtraReport

I'm sorry for not being able to explain this but now I'll elaborate what I want to do. I'm working on a .NET software(Windows Form, C#) with SQL Server, I'm using devexpress xtrareport(First time actually) for report printing and here comes my porblem, I have a table (let's call it invoice table) and it contains a column for products which contains table name for the products table of that invoice, each time the product table is new and I don't know how can I print that product table? How can I even add it as a datasource when It's not created yet.
you should not use the stock SqlDataSource, instead you should use the ObjectDataSource so you will manually fill the DTO and pass it to report

Crystal Report not displaying data when 1 of DataSet table is empty

I am using Crystal Reports and VS 2010. The Crystal Report is displaying data from 2 tables in a DataSet.
Table 1 (GetReceptionInfo) contains some info in the report header: name, Id, date, time.
Table 2 (SelectReceptionWork) contains records in the details part of the report.
When I am trying to view the CR when there are returned records in Table 2 the CR works fine, but when I try to view it when no records are returned (only in Table 2 but Table 1 HAS records) the Crystal Report is all empty.
I previewed Table 1 from the DataSet and it works fine, but not on the report.
I tried the following steps but the result is still the same (also verified the database after every single change):
Removed all links from Database Expert.
Set DataSet property of EnforceConstraints to False.
Deleted all primary keys on the DataSet.
Removed Table 1 from Database Expert and added it again.
Database Expert no links or indexes:
DataSet with no keys, tables are not related:
If the issue is not clear I can post a screenshot of the report, but I'm afraid it might not be clear because it is written in Arabic.
Option A: If GetReceptionInfo and SelectReceptionWorkWhen can be joined. Then you need to join the tables using a left join - not an equal join. When you are on the "Links" tab, click and drag from the field you want to join to the field you want to join to. This will create a little line. THEN, double-click on that line. It will pop-up a page which lets you pick which join type you want. Select "Left Outer Join"
Option B: If GetReceptionInfo and SelectReceptionWorkWhen are not intended to be joined, then your best bet is to remove the header table (GetReceptionInfo) from the main report. Only include the table SelectReceptionWork. This should list all the data you want. But then you still need to display that header information. So for that, create a SubReport that uses only GetReceptionInfo as its data source, and add that SubReport into the Report Header (or Page Header) section of the crystal report.

FastReport custom object as Datasource

I developed a simple print report in FastReport to print some details in table object.
Now I want to let my users to design and adjust their print report so I store report XML in database and load in FastReport Designer to user.
now to bind information in table.
We must add datasource in designer from database only and after that a connection is open and select all records to user and ...
My problem is that I want to use Custom Entity Object as Datasource for report not database table. How can I do that?
So if possible when the user opens report designer he can adjust column remove or add and drag new columns from datasource to report table and when save that report.
I run print by passing list to RegisterData function of report and it is ok.
You can pass list of any objects to the RegisterData method, look at the DataFromBusinessObject example.

How to add the data source to the rdlc file in visual studio 2010?

I am new to windows desktop application development.
I want to generate a bill report that is the bill master details should be displayed once and the related items should be displayed in the tabular format.
I have created the data table in dataset. The data table is configured.
Now in the report design I am not able to see this table to drag the field to their proper position.
Please help how to do so.
Thanks in advance.
Adding datasets
First you have to add a Data Source in your Report. You can do this by using the Data Sources window in VS. Click the Add new data source and select what you want (I usually use object). In the Report Data window there is a folder 'Datasets'. If you right-click it you can add a dataset.
Data in a table
To visualize the dataset you can drag a Table from your Toolbox onto the report, select it, then right-click on the upper-left corner and select Tablix Properties. There you can bind a Dataset to the table. Choose which items you want to display in which column by clicking on the column and selecting a value.
Singular data (textbox)
You can set an expression on a textbox that retrieves a specific set of data from a dataset (you can also use this on table columns btw). You can do this by right-clicking the textbox en going to Expression. This will open up an Expression window that contains some sort of expression builder.
The expression I use to retrieve singular data is the following (not sure if this is the best approach but it's the only one I know):
First(Fields!MyField.Value, "MyDatasetName")
Basically I'm assuming there is only one row in my dataset (or that field is the same in all rows) so I'm just retrieving the first value.

Crystal Reports Omitting Data

This might be a pretty simple question but I'm a Crystal Reports newbie...I have a report where I want specific pages that have a corresponding column omitted. So for example say it has someone's name and information on every page, how would I use a column that for example has the state on it, to omit certain results, like I don't want any pages in the report generated from states that have the "state column" from the database equal to like "TX" or something. This isn't what I'm actually doing, but it's an example of the functionality I want.
I'm thinking it would be in either the group or record selection formulas but I'm not sure how to go about putting it together to not create a page for the results when a certain column is equal to a value.
-Thanks from a total Crystal Reports noob.
So each page of the report is one record in the result set (someone's name and information) and you want to exclude some pages based on the value of one of the columns?
Perhaps I'm not understanding the problem correctly but can't you just change the datasource query?
WHERE state <> 'TX'

Categories

Resources