Crystal Report in ASP.NET
-
Hi Friends, I m doing crystal report in asp.net2.0 using c#,i have written the code for crystal report dynamically getting the database connection from web.config file and i have created the crystal report manually making the database connection mapping the stored procedure.I m getting the output correctly.The problem is if i need to change the database server name means i should change only in web.config file,but i have given the connection for crystal report in code behind and crystal report manually.When i change the database server name in web.config file its not getting the effect only when i connect crystal report manually its getting connected.Sorry for long comments here is the coding for database connection.Please help me to solve the solution protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack == false) { string from = ""; string id = ""; string to = ""; string mode = ""; from =Request.QueryString["FromDate"]; id = Request.QueryString["id"]; to = Request.QueryString["toDate"]; mode =Request.QueryString["mode"]; ReportDocument rd = new ReportDocument(); rd.Load(Server.MapPath("TourOperator.rpt")); rd.SetParameterValue(0, mode); rd.SetParameterValue(1, id); rd.SetParameterValue(2, from); rd.SetParameterValue(3, to); GetServerName(rd); Session["torRep"] = rd; foreach (CrystalDecisions.CrystalReports.Engine.ReportObject obj in rd.ReportDefinition.ReportObjects) { if (obj.Name == "txtfromdate") { ((TextObject)obj).Text = from; } if(obj.Name=="txttodate") { ((TextObject)obj).Text = to; } } if (rd.Rows.Count > 0) { CrystalReportViewer1.Visible = true; CrystalReportViewer1.ReportSource = rd; CrystalReportViewer1.DataBind(); } else { CrystalReportViewer1.Visible = false; ltl.Text = "<b><font color='red'>No Records Found</font></b>"; } } else { CrystalReportViewer1.ReportSource = (ReportDocument)Session["torRep"];