Click here to Skip to main content
15,914,795 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Sir/Madam
I am using Visual studio 2008 and inbuilt sql server 2005. I am trying to generate dynamic crystal report.My code is given bellow.

C#
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["config"]);
SqlCommand cmd = new SqlCommand("select custname,contact,fax,bill_add,shpng_add, item_name,model,serialno,quantity,net_amnt,vat,total_amnt from customer,bill", con)         con.Open();
 DataSet ds = new cusbill();
 SqlDataAdapter daa = new SqlDataAdapter(cmd);
 daa.Fill(ds.Tables[0]);
 ReportDocument rdoc = new ReportDocument();
 rdoc.Load(Server.MapPath("CrystalReport.rpt"));//Error occur in the statement
     if (ds.Tables[0].Rows.Count > 0)
       {
                rdoc.SetDataSource(ds);
                crysview.ReportSource = rdoc;
                //crysview is the object of Crystalviewer which has been define in the fronend.
        }
 con.Close();
}


Error message is that rdoc loading fail.
Please help me.
Thank you
Posted
Updated 15-Jun-11 23:26pm
v2
Comments
Wayne Gaylard 16-Jun-11 5:27am    
Added Pre tags for code.
Uday P.Singh 16-Jun-11 6:12am    
is this the web or window?
panku.in07 16-Jun-11 7:02am    
web...

I think the answer lies in the address you have given for the report.
C#
rdoc.Load(Server.MapPath("CrystalReport.rpt"));


should maybe be something like :

C#
rdoc.Load(Server.MapPath("C:\Reports\CrystalReport.rpt"));


Hope this helps
 
Share this answer
 
Comments
panku.in07 16-Jun-11 5:38am    
sir i tried but itz not working ..giving error
C:\Users\sony\Documents\Visual Studio 2008\MMS\CrystalReport.rpt //i used this
Uday P.Singh 16-Jun-11 8:52am    
what error message are you getting by using this..
try this:

MIDL
string paths="C:\Users\sony\Documents\Visual Studio 2008\MMS\CrystalReport.rpt";
            
            rdoc.Load(paths);
            rdoc.SetDataSource(ds);
            crystalReportViewer1.ReportSource = rdoc;

and tell me whts the O/P.
 
Share this answer
 
Comments
panku.in07 19-Jun-11 12:37pm    
sir,
itz giving error on this line
string paths="C:\Users\sony\Documents\Visual Studio 2008\MMS\CrystalReport.rpt";
thank you

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