Print Page | Close Window

Query For Subreport

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=19095
Printed Date: 02 May 2024 at 4:08pm


Topic: Query For Subreport
Posted By: Ganesh Khuspe
Subject: Query For Subreport
Date Posted: 13 Feb 2013 at 12:14am
Hey Hi Guys,

Can Anybody tell me how can i use query to retrieve data from SQL server DB to my SubReport of Main Report as i dint got any solution after search on it...As i m new to Crystal report so please help me to get sort this prob...

Thanks in advance...



Replies:
Posted By: Sastry
Date Posted: 13 Feb 2013 at 6:53am
HI
 
Open crystal reports--create a DSN to connect to your SQL server and choose tables and fileds which required to fill your report.
 
Sub report is nothing but a report which is incorporated in another report.
 
Here you create two separate reports and combine as one.


-------------
Thanks,
Sastry


Posted By: Ganesh Khuspe
Date Posted: 13 Feb 2013 at 8:59pm
Thanks for Reply sastry,
Actually i have made report in which i have fetched data from 5 tables..Now i want to make sub report and for dat i have to fetch data from 4 tables by joining those tables in sql..so how to do dat?


Posted By: Sastry
Date Posted: 13 Feb 2013 at 11:40pm
Hi

Go in Insert Menu-- Select Sub report -- It will ask for two options.. one is insert a existing one or create a new one.

Select new one and create sub report using 4 tables, finally it will ask you where to insert your sub report, choose the appropriate section.



-------------
Thanks,
Sastry


Posted By: Ganesh Khuspe
Date Posted: 14 Feb 2013 at 12:51am
I have Added Subreport in Main Report as u said..but not

able to understand how to add tables into it as i have

used dataset while making subreport connection because i

want to fetch data through query..And i want retrieve some

fields from all those 4 tables by joining those

tables...what can i do?


Posted By: Sastry
Date Posted: 14 Feb 2013 at 1:16am
Hay Ganesh..

1st Point :  You want to add 4 tables query or 4 tables ?  Query is some thing which you are writing SQL on your own.

2.Even though your main report consist of all 4 tables, you need to reselect those tables while creating sub report.

3.For time being forget you are preparing a sub report.  Do the following :
--Create a new report by creating a datasource (DSN/OLE DB /Native etc.)
--Now select the tables and join them (or) if you want to write your own SQL then click on Add Command under datasource connection and past your SQL.
--Now choose your fields and save the report.

4.  Now open your actual Main report and go in Insert Menu--Sub Report-- and select the above report and place it.





-------------
Thanks,
Sastry


Posted By: Ganesh Khuspe
Date Posted: 14 Feb 2013 at 1:38am
I got it what u r saying...I have made the report...n it is working properly..but when i m adding it in the main report then it is not showing me the data ...i want data on he basis of main report field..wat to do?


Posted By: Sastry
Date Posted: 14 Feb 2013 at 1:58am
Hi

You need to link your sub report to main report. 

You can link through Parameters, Fields or Formulas.

Right click on sub report and go in change sub report links and link


-------------
Thanks,
Sastry


Posted By: Ganesh Khuspe
Date Posted: 14 Feb 2013 at 2:12am
For my main report i m having intime and outime as parameters in query, and my subreport i used the same parameters..when i m linking the subreport to main report there are no intime and outime found as it is not in main report..now m confused how to bind both the report..can u plz help me?


Posted By: Sastry
Date Posted: 14 Feb 2013 at 2:34am
HI

Check the data types of these parameters.. if your main report parameter is string and sub report parameter is number then it will not show.




-------------
Thanks,
Sastry


Posted By: Ganesh Khuspe
Date Posted: 14 Feb 2013 at 2:58am
all the datatypes are same bt linking to main report not done...my main report doesn't have any parameter which will match to subreport field..wat to do?


Posted By: Ganesh Khuspe
Date Posted: 14 Feb 2013 at 6:46pm
Hi Sastry...I worked on Subreport n now I got an good experience of creating subreport..thanks to u..And 1 thing while making an parameters How to set datatype as i means that i have not understood properly..i was getting an error 'ADO Error Code Conversion Failed while converting datetime to Char String...'



Print Page | Close Window