How to set two table in Data Source in Crystal Report - asp.net

I have an issue in Crystal Report where in , I need to print on Crystal Report where values comes from three tables:
1-teach_details
2-MasterTeacherDetails
3-MasterTeacherSpecimenDetails
So, for this I have used data table which has all the fields necessary. On crystal Report, Report header section has teach_details values , on detail section MasterTeacherDetails and then MasterTeacherSpecimenDetails , for this I have query as :
Select teach_details.IdentityCode,IdentityName,dbo.fun_UniIdToUniName(UniId) as UniversityName,teach_details.Address+', '+dbo.fun_CityIdToCityName(teach_details.StateID, teach_details.CityID)+', '+dbo.fun_StateIdToStateName(teach_details.StateID)+', '+teach_details.PinCode as IdentityAddress, dbo.fun_GradeIdToGradeName(teach_details.Grade) as Grade, case when teach_details.TypeOfIdentity='College' then dbo.fun_StrIdToStrName(teach_details.Streams) else case when teach_details.TypeOfIdentity='Coaching' then dbo.fun_ExamIdToExamName(teach_details.Exam) else dbo.fun_StanderdIdToStanderdName(teach_details.Standerd) end end as Strm_Exam_Standard, TeacherName+'/'+MasterTeacherDetails.TeacherCode as TeacherName, case when MasterTeacherDetails.TypeOfIdentity='College' then dbo.fun_StrIdToStrName(MasterTeacherDetails.Stream) else case when MasterTeacherDetails.TypeOfIdentity='Coaching' then dbo.fun_ExamIdToExamName(MasterTeacherDetails.Exam) else dbo.fun_StanderdIdToStanderdName(MasterTeacherDetails.Standerd) end end as TeacherStr_Exm_Stnrd, case when SameAddress='True' then teach_details.Address+', '+dbo.fun_CityIdToCityName(teach_details.StateID, teach_details.CityID)+', '+dbo.fun_StateIdToStateName(teach_details.StateID)+', '+teach_details.PinCode else MasterTeacherDetails.Address+', '+dbo.fun_CityIdToCityName(MasterTeacherDetails.StateID,MasterTeacherDetails.CityID)+', '+dbo.fun_StateIdToStateName(MasterTeacherDetails.StateID)+', '+MasterTeacherDetails.PinCode end as TeacherAddress, MasterTeacherDetails.Mobile as TeacherMobileNo,MasterTeacherDetails.EmailID as TeacherEmailID,Case MasterTeacherDetails.DOB when '01/01/1900' then '' else Convert(varchar(10),MasterTeacherDetails.DOB,103) end as DOB,MasterTeacherDetails.Remark ,BookCode,BookCode as BookName,BookCode as AuthorName,DispatchThrough as Mode,Qty from teach_details inner join MasterTeacherDetails on teach_details.IdentityCode=MasterTeacherDetails.IdentityCode inner Join MasterTeacherSpecimenDetails on MasterTeacherDetails.TeacherCode=MasterTeacherSpecimenDetails.TeacherCode where (teach_details.TypeOfIdentity ='College' and (teach_details.CityID = 'GHAZIA')) order by IdentityName
Now, the problem here is that MasterTeacherDetails and MasterTeacherSpecimenDetails have different number of rows,Suppose
MasterTeacherDetails has a,b,c and MasterTeacherSpecimenDetails has d,e,f,g,h
So when I run it with data it shows me 5 lines of entry and MasterTeacherDetails rows repeats itself 5 times, like :
Rather it should display:
I cannot use sub report for showing specimen details section and main report for showing Teacher Details Section.
So please help, and please try to be least technical as I am not very efficient on C#.net yet.

From what I gather by reading your question and comments, it seems like you would like a summary, then also have the specimen listings on separate pages for each teacher so that you can separate the report and give them each their listing.
Also, it seems that you want to do this with only one SQL query, meaning one command table.
I would begin with grouping by teacher for both sections of the report.
For the specimen detail section, you can hide the group header and footer. Use the group expert paging settings to create a new page after each teacher group to get each teacher on different pages to distribute the sections of the report. Also, you'll probably want the page numbers to restart after this group. I don't think you can do this through group expert; you'll probably need to do this through section expert on the group footer paging settings.
For the teacher detail section, also use the grouping by teacher to show the "teacher detail" in the group header or footer, then suppress the detail section using section expert. This will eliminate your multiple lines. I would put the teacher details in a sub-report in the report header section, and use the section expert to create a new page after the report header section. This is like a dedicated front page.

Please use DataSet instead
DataSet dsReport = new DataSet();
dsReport.Tables.Add(dataTable1);
dsReport.Tables.Add(dataTable2);
yourReport.SetDataSource(dsReport)

Related

How to generate mutiple pages with BIRT Report Designer

I would like to generate multiple page of a report. The number of pages would be defined in a variable from a Data Set.
example: if the variable is set to 5, the report would be generated in 5 copies (1/5, 2/5.. 5/5).
I'm using BIRT Report Designer 4.4.0.
The rest of the report is filled with other data that would stay the same in the n pages.
I managed to show the page number and the total number of pages (the variable) but didn't manage to generate that amount of pages.
I have no clue how to proceed, so until now, I only manage to generate 1 page.
You can use either a scripted data set or some SQL statement (for e.g. on Oracle something like this)
select rownum from user_objects where rownum <= :pi_num_copies
to create a "for-loop" data set.
I would try the following.
Insert (into the report) a Table binded to your Data Set with a
single column - your "NumberOfCopies" field.
Add Group for the NumberOfCopies.
Put your repeating n-times data to the Table Detail (you can replace the original field with it). Add fixed (for
every page) info to Group header and footer.
Set After property to Always in Page Break paramener
section for Group Footer (not for table's one!)
I guess it will work. If not - play around with Page Break options in Table Footer and Detail...

Count and other calculations on displayed records only

I am trying to display counts (and other formulas) for only the records being displayed.
When I put count #Field in the report (wherever I put it) I get too many records. I have no suppression formulas present.
I do have formulas in Select Expert, Record. However, I understood that counts should work after these formulas have been applied.
The total number of records showing at the bottom of the report is 799999. When I use count #Field I also get 799999. However, when I export information in Details into excel I get 28140. This is the number of rows of data displayed and what I need to get count etc on.
I have looked at numerous posts re "whileprintingrecords" and "runningtotals" but cannot seem to get anything to work and not sure what I need to do and where?
Thanks
Ian
In your page footer section place text field and there you can place special field
and using that "record number" in page footer you can access number of records until that page.
So on page 1 there could be
Record 5 of 799999
on page 2
Record 12 of 799999
etc...

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!

categories and sub-categories dropdown form

Please help me determine the correct code for my drop-down search form. I want to be able to populate from a drop down: Categories – Sub Categories - Sub Sub Categories – Sub Sub Sub Categories. Here is how the form is displaying: Select a state – Select a County – Select a City – Select a Zip Code.
Also, When I select the first category It immediately display results; is there a way to stop the results from displaying after selecting but only populate the next sub category, and add a submit button to the bottom of the form that will display results?
I’m a newbie and I don’t mind paying a fee for your time. Thanks a lot for your help,
John
This is a very complicated task:
You need to identify a data source, such as this one, for a list of states, counties, cities and zipcodes in the U.S. provided in XML/JSON format.
You need to create a jQuery script that shows the right select dropdown depending on the prior section (using the data feeds above).
It's impossible to show an example here, because it depends on the language that you want to use, data sources, etc. If you don't have these expertise, you can post the job on any number of job sites.
I hope this helps.

Crystal Report with Multiple Tables - Empty or Cartesian Product

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.

Resources