Print Page | Close Window

Records are repeated in report

Printed From: Crystal Reports Book
Category: Crystal Reports .NET 2003
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=15413
Printed Date: 19 Apr 2025 at 1:18am


Topic: Records are repeated in report
Posted By: sankari
Subject: Records are repeated in report
Date Posted: 19 Jan 2012 at 7:46pm
this is codebehind  sql quer
 
string sql = "SELECT nav.scheme_name,portfolio_master.amt_invested from portfolio_master inner JOIN nav ON nav.scheme_code=portfolio_master.scheme_id and  portfolio_master.user_id='" + Session["user_id"] + "' order by nav.scheme_name";

ReportDocument portfolio1 = new ReportDocument(); 

        string reportpath = Server.MapPath("my_port.rpt"); 
       portfolio1.Load(reportpath);

             portfolio1.SetDataSource(ds.Tables[0]);

        portfolio1.Refresh();

        CrystalReportViewer1.ReportSource = portfolio1;

        CrystalReportViewer1.Visible = true;

 
I have tested this query in SQL server and it fetches 9 records.
 
In the report, I have added 2 tables and the sql expression is as below:
 SELECT "NAV"."Scheme_name", "portfolio_master"."amt_invested"
 FROM   "portfolio"."dbo"."portfolio_master" "portfolio_master" INNER JOIN "portfolio"."dbo"."NAV" "NAV" ON "portfolio_master"."scheme_id"="NAV"."Scheme_Code"
 
 
this result in each record displaying 14 times .
1.why this repetition
2. How do i give the user id control ( which is missing in report SQl query)
 
If needed I can attach the screen shots.
 
 
 
 
 
 
 



Replies:
Posted By: lockwelle
Date Posted: 20 Jan 2012 at 9:25am
so, the first question, is does it return 14 records when you don't join on the user_id?
 
CR doesn't know about Session variables...ok, it might, but I don't program for the web.  From an application persepective, I would create a parameter for the user id and then have the application supply the value.
 
I don't know the exact code, but you would access the parameters of the report similarly to how you are access the dataSource.
 
HTH



Print Page | Close Window