Advertisement
Guest User

Untitled

a guest
Dec 1st, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. var p = Request.QueryString["P"].ToString();
  2. var appId = int.Parse(Request.QueryString["appId"].ToString());
  3. var HE = new HIVAIDSEntities();
  4. var app= HE.ApplicatioNames.FirstOrDefault(x => x.Hivrp_app_name_pk == appId);
  5.  
  6.  
  7.  
  8. **//SQLReport report = new SQLReport();**
  9. var report = new ReportDocument();
  10. **// Application.StartupPath**
  11. report.Load(filename: Server.MapPath(p));
  12. **//Get SQL Server Details**
  13. string zServer = app.Hivrp_server_name;
  14. string zDatabase = app.Hivrp_database_name;
  15. string zUsername = app.Hivrp_user_id;
  16. string zPassword = app.Hivrp_password;
  17.  
  18. var ciReportConnection = new ConnectionInfo
  19. {
  20. ServerName = zServer,
  21. DatabaseName = zDatabase,
  22. UserID = zUsername,
  23. Password = zPassword
  24. };
  25.  
  26.  
  27. **//Assign data source details to tables**
  28.  
  29. foreach (CrystalDecisions.CrystalReports.Engine.Table table in report.Database.Tables)
  30. {
  31.  
  32. table.LogOnInfo.ConnectionInfo = ciReportConnection;
  33. table.ApplyLogOnInfo(table.LogOnInfo);
  34.  
  35. }
  36.  
  37.  
  38. **//Assign data source details to the report viewer**
  39. if (this.CrystalReportViewer1.LogOnInfo != null)
  40. {
  41. TableLogOnInfos tlInfo = this.CrystalReportViewer1.LogOnInfo;
  42. foreach (TableLogOnInfo tbloginfo in tlInfo)
  43. {
  44. tbloginfo.ConnectionInfo = ciReportConnection;
  45. }
  46. }
  47. CrystalReportViewer1.ReportSource = report;
  48. CrystalReportViewer1.ToolPanelView = CrystalDecisions.Web.ToolPanelViewType.None;
  49. CrystalReportViewer1.DisplayPage = true;
  50.  
  51. CrystalReportViewer1.RefreshReport();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement