How can I add unknow Table as source for XtraReport - c#

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

Related

DataGridView with dynamic columns to RDLC report

I'm trying to print a report (RDLC) that contain the same data presents in a dataGridView.
This is the DGV:
The first 3 columns are static, the others one are dynamic. This DGV is loaded from a DataTablethat I create from a series of Query.
What i would like to do is print this table using the same DataTable.
This is what I've already tried:
I tried with Matrix table in RDLC using my query and it works ok but the query only returns rows with data, so for the first row it only print 36-12,20 and 38-12,50. The query is quite complex.
I've tried to create a DataTable with the same columns of the DGV's one to use in the creation of the reports. I can create the report with this but nothing is printed because my column's name doesn't match with the one in the original table (They're dynamic so...)
I tought i could also create a dummy db table with all the data I need with fixed columns (let's say max 20) and than just use that to create my report, not really a fan of this approach.
Any clue?

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.

Combine two datasets in one Crystal Report

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.

"Dereferencing" data from a databound GridView

I have a GridView that is bound to a select statement from a table. That table contains a lot of keys out to other tables that are just IDs. I would like the GridView to "dereference", as it were, the id of the field in question and display the human-readable name found in the other table.
At the moment, the options that come to my mind are composing a DataSet by hand in the codebehind and binding the GridView to that instead of the SqlDataSource or creating a stored procedure to return the table already "dereferenced". Any other ideas or recommendations for this situation? I am using .NET 2.0 per employer mandate.
I am not entirely sure what you mean by "dereferencing" but if you just want to display the value from the tables refered to by foreign keys then just bind your gridview to a query that joins all the required tables in a flat dataset. e.g.:
SELECT Table1.Field1, Table1.Field2, Table2.Field1, Table2.Field2
FROM Table1
LEFT OUTER JOIN Table2 on Table1.Table2ID=Table2.ID
This can be done either in a stored procedure or by directly specifying this as the SelectCommand property.
I just ended up creating a view that automatically dereferenced the ids to the other tables and using that for the basis of the GridView.

Categories

Resources