Crystal Report with Multiple Tables - Empty or Cartesian Product - asp.net

I know this has been asked before..sort of. And that's why I'm posting. Basically I'm building a report in Crystal that relies, to keep this simple, at least 3 tables.
Table A is inner joined to table B by a unique ID. Table B has a child table that may or may not have data related to this unqiue ID.
As a general example table A is a customer table, table B is a product table and the child table is contains the product number. All customers have a product, but not all customers have product number in the child table. I hope I've explained that simply enough.
My issue is sort of between Crytal and Access and how to query this. When I'm writing behind something in VB it's easy enough to write and execute a query and display the result in the desired manner. However I can't seem to get my query straight... I either end up with a report with cartesian product as the resultset, which displays ok...except that even with the few records I have ends up being about 30k pages..or I end up with a blank dataset because the child table does not have corrisponding data to B.
Using outter joins I've managed to get my results within some amount of reason but not acceptable to a real world report. I'm sure this issue has come up but I can't seem to find any suitable answers and to be honest I'm not even sure what questions to ask being a Crystal n00b.
What I'm really after is the data from Table A, the data from Table B and children tables. While they are logically linked and can be linked with the ID field, it isn't necessary I don't think because I am taking a parameter value for the report of the ID field. And once the tables are filtered, no other action needs to be taken except to dump them back on the report.
So can anybody point me in the right direction? Can I set up individual datasoruces (unrelated) based perhaps in a seperate section? Should I build a tree of queries and logic in my DB to get what I need out? I've been racking my brain and can't seem to find the right solution, any and all advice is apreciated and if I can clarify anything or answer any questions I will.
Thanks in advance.
As per requested below:
Section1
ID fname lname
01 john smith
Section2
ID notifiedDate notifiedTime
01 10/10/2012 12:35PM
S2childAdmin
ID noteName
01 jane doe
This data is logically related and can be related in the DB. However it is not necessary as long as the ID parameter is passed to each table. Querying Section1 inner joined with Section2 works fine. But any other arrangements result in more rows than required and I end up with a report many times duplicated. What I really need is something like Section1 joined with Section2 and S2childAdmin as a freely availble table. Otherwise it multiplies my data or results in a null recordset (because it can return 0 rows)

I think this should help point you in the right direction, though it has been 5 years or so since I did heavy Crystal Reports work.
One option might be to join everything using Outer Joins like you stated you were, then use a Crystal Report 'group' on the Table A ID, with a group based upon Table B ID inside of that. So you would, in the actual 'Detail' area put your table C details if there were any, and then use the Group header/footer for Table A and Table B to show data specific to those objects.
Another possible solution that may fall short of your requirements but might get you thinking in another way, is to create your main report and in it, display the fields from table A. Then below those fields include a sub-report and pass in the unique ID from Table A. You will then have a query inside of the subreport that finds all of the Table B records with that Table A.ID value and displays their details.
At this point you run into a weakness of Crystal Reports (at least as of the last version I used) in that you cannot have a subreport inside of a subreport.

Related

Report with four tables for each account

I am struggling in the creation of a report including four tables.
Those tables should be the same for each account. I use just one dataset. When I run the report, the data is good, but tables listing appears wrong.
First all BALANCE DETAIL tables for all accounts selected are listed, then all DEBIT TRANSACTION tables for all accounts selected are listed etc.
For each account the page should show up just like this
Please give me an easy-to-understand answer since I am really a beginner in this sector.
It might be easier to this with 5 separate datasets, but I think you can do it with just on also.
Create on 'main' table on the dataset. use 4 detail rows, 1 column
Group it on accountnumber
In each detail of the main table, insert a new table with the same dataset.
Group those sub-tables also on accountnumber
Add a filter to the subtables. set the subtable accountnumber equal to the outer table account number (you can use the expression builder, but it should read something like this: row['ponum'] equals row._outer["ponum"] )
Good luck!

How do I create a running count of outcomes sequentially by date and unique to a specific person/ID?

I have a list of unique customers who have made transactions over a year (Jan – Dec). They have bought products using 3 different methods (card, cash, check). My goal is to build a multi-classification model to predict the method pf payment.
To do this I am engineering some Recency and Frequency features into my training data, but am having trouble with the following frequency count because the only way I know how to do it is in Excel using the Countifs and SUMIFs functions, which are inhibitingly slow. If someone can help and/or suggest another solution, it would be very much appreciated:
So I have a data set with 3 columns (Customer ID, Purchase Date, and Payment Type) that is sorted by Purchase Date then Customer ID. How do I then get a prior frequency count of payment type by date that does not include the count of the current row transaction or any future transactions that are > the Purchase Date. So basically I want to do a running count of each payment option, based on a unique Customer ID, and a date range that is < purchase date of that training row. In my head I see it as “crawling” backwards through the transactions and counting. Simplified screenshot of data frame is below with the 3 prior count columns I am looking to generate programmatically.
Screenshot
This gives you the answer as a list of CustomerID, PurchaseDate, PaymentMethod and prior counts
SELECT CustomerID, PurchaseDate, PaymentMethod,
(
select count(CustomerID) from History T
where
T.CustomerID=History.CustomerID
and T.PaymentMethod=History.PaymentMethod
and T.PurchaseDate<History.PurchaseDate
)
AS PriorCount
FROM History;
You can save this query and use it as the source for a crosstab query to get the columnar format you want
Some notes:
I assumed "History" as the source table name - you can change the query above to use the correct source
To use this as a query, open a new query in design view. Close the window that asks what tables the query is to be built on. Open the SQL view of the query design - like design view, but it shows the SQL instead of the normal design interface. Copy the above into the SQL view.
You should now be able to switch to datasheet view and see the results
When the query is working to your satisfaction, save it with any appropriate name
Open a new query in design view
When you get the list of tables to include, switch to the list of queries and include the query you just saved
Change the query type to crosstab and update the query as needed to select rows, columns and values - look up "access crosstab queries" if you need more help.
Another tip to see what is happening here:
You can take the subquery - the parts inside the () above - and make
just that statement into it's own query, excluding the opening and closing (). Then you can look at it's design view to see what it does
Save it with an appropriate name and put it into the query above in place of the statement in () - then you can look at the design view.
Sometimes it's easier to visualize and learn from 2 queries strung together this way than to work with sub queries.

I want generate a crystal report with multiple Sub details involve multiple tables

i display data in grid like this and want a crystal report like this print the data.
but i have no clue how to do this. Let me try to explain further this case.
for every row of main table i have displayed subdetails in subgridvew and this subgrid data is fetched by keys in main table and an other table (this table has fixed values).
this would be first report i would create.
please gimme clue or tell if i am not so clear about asking question
For this kind of requirement you need to use cross tab...where in rows you need to provide data from table 1 and for rows first take data from table then from table 2 which will geoup as per your requirement

Use the same sql Server table to do different updates, is there a way to do that?

Im using Asp.net (VB.net), in my Database :
have One table called (Trade), the same rows of this table are used from 3 different users, These users can make different updates on this table, they should see the basic informations of the table (I mean by the Basic, before the table (trade) has been updated)
The problem is here when the first user wants to modify the table's rows, the second and third user cannot see the basic information any more, and if they decide to change or update some data, the first will lose his updated rows..
The data will be overwritten every time the users make updates on the table.
What I want, is to know if there is a way to do like a copy, or an image of the table for the 3 users, and every user can update normally, without creating the same Table with the same rows 3 times??!
Update
My table structure is: Trade(trName, Carrier, POl, POD, Vgp, Qgp) There is no primary key..
Thank you..
Solution to your problem could be two copies of the original table. Show the original table always to the user as the initial data. And in second table keep the updated data always. Now the trick comes here to maintain the log, for that you have to maintain the log table, this table will have all the fields of original table along with one additional column "UserId", this will have the ID of user who has changed the value. Now each time before updating the data, copy it in the log table. If this suits your need then post the fields of your table then we can workout on the table structures.

Delete records in axapta very slow

I've got a form in ax 2009, showing filtered records of a table (about 5.000.000 records total, about 1000 shown filtered).
Selecting a couple of those records in the form and deleting them via form-control (alt+f9) is very slow.
One record is deleted immediately, selecting about 20 takes several minutes!
There is only one deleteAction on the table - any idea what could thwart the operation?
edit:
The regarding table has two indices, both don't allow duplicates. First one is an index on an integer field, second one is a combined one of three fields.
createRedIdIndex is not activated.
The filter makes use of one column ( employeeID ) in a queryBuildRange.
deleteAction: another table (B) references the id ( indexed ) of the mentioned table (A). A has a deleteAction on B. setting is "cascade"
The two tables are related via id-field.
The relations can be resolved by an index.
And it's only an amount of about 20 records I want to delete - so I don't go in line with the idea, that the "to-delete-data-amount" is too big!
Also have a look on this:
http://blogs.msdn.com/b/emeadaxsupport/archive/2010/07/12/forms-with-a-high-number-of-records-take-a-significant-time-to-show.aspx
Consider adding
grid.autoSizeColumns(false);
as suggested in the article.
Do diagnose database performance issues in AX, enable SQL tracing in Tools\Setup in the SQL tab page.
Use the code profiler to see where the time is used.

Resources