private void GetReport(string EmpID, string StartDate, string EndDate, string Conn, string Cmpid) { try { TableLogOnInfos TableLogOnInfos = new TableLogOnInfos(); TableLogOnInfo TableLogOnInfo = new TableLogOnInfo(); ConnectionInfo ConnectionInfo = new ConnectionInfo(); SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(); Tables Tables; ReportDocument report = new ReportDocument(); string FileName = "~/MA723BA.rpt"; report.Load(Server.MapPath(FileName)); if (Conn != "") { string ConnString = ConfigurationManager.ConnectionStrings[Conn].ConnectionString; if (ConnString.ToLower().StartsWith("metadata=")) { System.Data.Entity.Core.EntityClient.EntityConnectionStringBuilder efBuilder = new System.Data.Entity.Core.EntityClient.EntityConnectionStringBuilder(ConnString); ConnString = efBuilder.ProviderConnectionString; builder.ConnectionString = ConnString; ConnectionInfo.ServerName = builder.DataSource; ConnectionInfo.DatabaseName = builder.InitialCatalog; ConnectionInfo.UserID = builder.UserID; ConnectionInfo.Password = builder.Password; Tables = report.Database.Tables; foreach (CrystalDecisions.CrystalReports.Engine.Table table in Tables) { TableLogOnInfo = table.LogOnInfo; TableLogOnInfo.ConnectionInfo = ConnectionInfo; table.ApplyLogOnInfo(TableLogOnInfo); } } } ParameterRangeValue myParameterRangeValue = new ParameterRangeValue(); myParameterRangeValue.StartValue = StartDate; myParameterRangeValue.EndValue = EndDate; report.SetParameterValue(0, EmpID); report.SetParameterValue(1, myParameterRangeValue); CrystalReportViewer1.ReportSource = report; CrystalReportViewer1.DataBind(); } catch(Exception er) { throw new Exception(er.ToString()); } }
catch(Exception er) { throw new Exception(er.ToString()); }
catch (Exception ex) { throw; }
try..catch
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)