Click here to Skip to main content
15,886,788 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hii,,

i am making a report in c#. but there is a problem when i set parameter in c# by coding it display only one record.

i send a multiple values from listbox but display only one in Crystal Report.

i use :

for(int i=0;i<code.length;i++)>
                {
                    strSelection=strSelection+"'"+code[i]+"'"+",";
                }

                strSelection = strSelection.Substring(0, strSelection.Length - 1);
                string str = "select crbal*-1 as crbal,glname, glcode,contprsn, refby, glphone1, glcity, glphone2, email, crlimit, restorddueamt  from glmast WHERE drgroup='A3402' and crbal<>0 and glcode in(" + strSelection + ")";
                SqlDataAdapter ad = new SqlDataAdapter(str, con2);
                DataSet ds = new DataSet();

                ad.Fill(ds);

                path = Server.MapPath("Debtors_Total_Outstanding_Report.Rpt");
                cr = new ReportDocument();
                cr.Load(path);
                
                cr.SetDataSource(ds.Tables[0]);
              
                cr.SetParameterValue(0,ds.Tables[0].Rows[0][1].ToString());
                cr.SetParameterValue(1,company_name);
                cr.SetParameterValue(2, database_name);
                       
                CrystalReportViewer1.ReportSource = cr;
                CrystalReportViewer1.DataBind();



please help me...

There are Three parameters in My Crystal Report.

Thanks and Regards....
Mitesh
Posted
Updated 24-Jun-12 22:35pm
v2

Please check your .rpt file.
Is there any grouping existing or not. Because your report print wrong data.
 
Share this answer
 
Comments
[no name] 25-Jun-12 5:17am    
yes there is a grouping on Glname.
[no name] 25-Jun-12 5:26am    
please tell me How to set parameter in Loop Wise.... beacuse it takes one record only.
Savalia Manoj M 26-Jun-12 0:49am    
Remove that group and set Parameter on report.
If You want to print multiple time same value then set datatable to source. And then print those field in detail section.
Crystal report not support dynamically parameter. Once you add parameter in crystal report that parameter you have to pass.
In your case you want to set it using loop. your datatable contain many record so you have to set it as source and print it in detail section.
Other wise give me your exact definition what you want to print. So i can help you..
 
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