Click here to Skip to main content
15,918,742 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a crystal report and bind the dataset to it.everything goes good but where i'm sticking is in the code behind i'm getting the above error near the "rep.setdatasource".
here is my code. (vs2008 ,net framework 3.5 and c#)

C#
protected void  Viewbutton_Click(object sender, EventArgs e)
            {
                string path = Server.MapPath(@"CrystalReport.rpt");
                SqlConnection con = new SqlConnection("Data Source=HOME-PC\\SQLEXPRESS;Initial Catalog=test1;Persist Security Info=True;User ID=user1;Password=user1");
                con.Open();
                SqlCommand cmd = new SqlCommand();
                cmd = new SqlCommand("select * EMaster", con);
                SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                da.Fill(ds, "Infotable");
                ReportDocument rep = new ReportDocument();
                rep.Load((path));
                CrystalReportViewer1.RefreshReport();
                rep.SetDataSource(ds.Tables["Infotable"]);
                //rep.SetDataSource(ds.Tables[0]);
                CrystalReportViewer1.ReportSource = rep;
            }



Can anyone please figure my flaws.
Thanks in advance.
Posted
Updated 14-Feb-14 21:48pm
v3
Comments
JoCodes 15-Feb-14 3:24am    
Try rep.SetDataSource(ds);
[no name] 15-Feb-14 4:22am    
i tried that but that also sounds bad no use:(
and i'm not getting error in the parameter of setdatasource. The actual error is "it shows as reportdocument does not contain definition for setdatasource" [-by underlining the setdatasource with red dotted line]

1 solution

Hi
The above Problem was resolved actually i have declared reportdocument as class as well as used its desired namespace " using CrystalDecisions.CrystalReports.Engine;" so it throws an error.now i removed the class so that previous error flew away.


Thanks for all who responded.
 
Share this answer
 
Comments
thatraja 17-Feb-14 3:13am    
5! for posting answer for your question. Keep doing this always
[no name] 17-Feb-14 3:17am    
Ok thanks

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