Click here to Skip to main content
16,021,115 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all, I have a crystal report that displays data from a dataset. When i run the program it does not display any data but the dataset has a number of records. It shows an error 'value does not fall within the expected range'. I do not use any parameters in crystal report.
Help me. Thanks.
The code is follows.

C#
private void Form1_Load(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();
            ds.Tables.Add("Doctors");
            Get_Doctors();
            CrystalReport1 rpt = new CrystalReport1();
            rpt.SetDataSource(ds);
            crystalReportViewer1.ReportSource = rpt;
        }
        private void Get_Doctors()
        {
            da = new SqlDataAdapter("SELECT D_Name,D_Address_L1 from doctors", Dbcon);
            da.Fill(ds, "Doctors");
        }
Posted
Updated 17-Jan-11 18:53pm
v2
Comments
Kasson 17-Jan-11 22:51pm    
What code you have written for this? Paste the code our expert will find the problem in code and then only it can be solved.

1 solution

Modify this line:
rpt.SetDataSource(ds);
to
rpt.SetDataSource(ds.Tables[0]);
OR
rpt.SetDataSource(ds.Tables["Doctors"]);
 
Share this answer
 
Comments
shaijuvjohn 18-Jan-11 1:23am    
but i have another table in the same dataset that has details of patients.
Sandeep Mewara 18-Jan-11 1:27am    
You cannot bind dataset and assume that all the tables would automatically be taken care of!

Have a look at this article to generate crystal report from multiple datasource: http://www.c-sharpcorner.com/UploadFile/mahesh/MultipleDataSourceReport08232006225431PM/MultipleDataSourceReport.aspx

That would help and resolve your issue.
shaijuvjohn 18-Jan-11 2:45am    
Thanks friend, it helped me lot.

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