Report Design
 Crystal Reports Forum : Crystal Reports .NET 2003 : Report Design
Message Icon Topic: Records are repeated in report Post Reply Post New Topic
Author Message
sankari
Newbie
Newbie


Joined: 19 Jan 2012
Location: India
Online Status: Offline
Posts: 1
Quote sankari Replybullet Topic: Records are repeated in report
    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.
 
 
 
 
 
 
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet 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
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.016 seconds.