Click here to Skip to main content
15,907,875 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello everybody,

i have window projet in which i want to bind crystal report with multiple query i have done by by adding command but the problem is that when i run the program it asking password and usernam of database every time and the take to much time to execute

i have only single crystal report and i want to bind it with more then one query like want to see all senior employee whose age greater then 50, and in next query i want to see all employee whose department is marketing in the same crystal report, but the problem is that it display only the first query result i bind my crystal report like that...

steps . add new item -> add crystal report -> create new connection -> chose database -> add table both (tb_Dept & tb_Employee) because i have id of dept. in my tb_Employee -> chose the field to display -> select format for crystal report -> finish
if(comboBox1.SelectedIndex==0)
           {
               //qry= "query for senior employee"
           }
           else if(comboBox1.SelectedIndex==1)
           {
            //qry= "query for marketing employee"
           }
           /* add namespace
             using CrystalDecisions.Shared;
             using CrystalDecisions.CrystalReports.Engine; */
           SqlDataAdapter adp=new SqlDataAdapter(qry,/*connection*/);
           DataTable dt=new DataTable("dt1");
           adp.Fill(dt);
           ReportDocument rd=new ReportDocument();
           rd.Load(Application.StartupPath+"\\CrystalReport1.rpt");
           crystalReportViewer1.ReportSource=rd;

the output is same only show the result of first query !
plz help me who one read this question.

Thanks in advance
Parveen Rathi
Posted
Updated 17-Apr-11 22:47pm
v3
Comments
Ankur\m/ 16-Apr-11 7:08am    
Multiple queries? Are you using sub-reports?
If not, create a stored procedure to get all required columns and use that procedure only.
thatraja 16-Apr-11 9:50am    
Include your code in your question...I'll give you the solution(BTW Already I guessed)
Parveen Rathi 18-Apr-11 6:24am    
Thanks Thatraja,
i want to take result of two query as in my question plz reply come online send mail pkrathi02@gmail.com
thatraja 18-Apr-11 11:16am    
Check my answer

BTW please always include your code, error messages, etc., in your question, so that you can get solutions quickly. Cheers.
sher ali 18-Apr-11 12:06pm    
brother please send me the solution also send by thatraja i have also this problem my mail sheralistar@gmail.com
thanks

You can use sub-reports. How are you binding reports? Through push or pull method? Include your code block,this will help in determining why you are being asked for Username and password.
check this article, it might help:link
Also, first try to test your report from the rpt file itself.
 
Share this answer
 
Here you go

Creating Crystal Report with Multiple Tables[^] (Nice article with good explanation(also with pictures))

OP wrote:
i have window projet in which i want to bind crystal report with multiple query i have done by by adding command but the problem is that when i run the program it asking password and username of database every time and the take to much time to execute

For that you should apply login at runtime.

C# Crystal Reports Dynamic Logon parameters[^]

Free attachment

Understanding the Login Failed Error in Crystal Reports[^]

Troubleshooting Database Login Errors using Crystal Reports with .NET[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900