Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var p = Request.QueryString["P"].ToString();
- var appId = int.Parse(Request.QueryString["appId"].ToString());
- var HE = new HIVAIDSEntities();
- var app= HE.ApplicatioNames.FirstOrDefault(x => x.Hivrp_app_name_pk == appId);
- **//SQLReport report = new SQLReport();**
- var report = new ReportDocument();
- **// Application.StartupPath**
- report.Load(filename: Server.MapPath(p));
- **//Get SQL Server Details**
- string zServer = app.Hivrp_server_name;
- string zDatabase = app.Hivrp_database_name;
- string zUsername = app.Hivrp_user_id;
- string zPassword = app.Hivrp_password;
- var ciReportConnection = new ConnectionInfo
- {
- ServerName = zServer,
- DatabaseName = zDatabase,
- UserID = zUsername,
- Password = zPassword
- };
- **//Assign data source details to tables**
- foreach (CrystalDecisions.CrystalReports.Engine.Table table in report.Database.Tables)
- {
- table.LogOnInfo.ConnectionInfo = ciReportConnection;
- table.ApplyLogOnInfo(table.LogOnInfo);
- }
- **//Assign data source details to the report viewer**
- if (this.CrystalReportViewer1.LogOnInfo != null)
- {
- TableLogOnInfos tlInfo = this.CrystalReportViewer1.LogOnInfo;
- foreach (TableLogOnInfo tbloginfo in tlInfo)
- {
- tbloginfo.ConnectionInfo = ciReportConnection;
- }
- }
- CrystalReportViewer1.ReportSource = report;
- CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;
- CrystalReportViewer1.DisplayPage = true;
- CrystalReportViewer1.RefreshReport();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement