code_junkie

Search Crystal Reports in Visual Studio and determine whether SQL table/proc is being used

Nov 13th, 2011
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. Public function tablesUsedByAReport(myReportName as string) as string
  2. Dim m_report As CRAXDRT.Report, _
  3. m_crystal As CRAXDRT.Application, _
  4. m_tablesUsedByAReport As String
  5.  
  6. Dim m_table As CRAXDRT.DatabaseTable, _
  7. m_section As CRAXDRT.section, _
  8. m_objet As Object, _
  9. m_subReport As CRAXDRT.SubreportObject
  10.  
  11. Set m_crystal = New CRAXDRT.Application
  12. Set m_rapport = m_crystal.OpenReport(m_nomRapport, 1)
  13.  
  14. 'table names in the report'
  15. For Each m_table In m_rapport.Database.tables
  16. m_tablesUsedByAReport = m_tablesUsedByAReport & m_table.location & ";"
  17. Next m_table
  18.  
  19. 'table names in each of the subreports'
  20. For Each m_section In m_rapport.Sections
  21. For Each m_objet In m_section.ReportObjects
  22. If m_objet.Kind = crSubreportObject Then
  23. Set m_subReport = m_objet
  24. Set m_report = m_subReport.OpenSubreport
  25. For Each m_table In m_rapport.Database.tables
  26. m_tablesUsedByAReport = m_tablesUsedByAReport & m_table.location & ";"
  27. Next m_table
  28. End If
  29. Next m_objet
  30. Next m_section
  31.  
  32. 'my tables list'
  33. tablesUsedByAReport = m_tablesUsedByAReport
  34.  
  35. End function
  36.  
  37. Public Function tablesUsedByAReport(ByRef report As CrystalDecisions.CrystalReports.Engine.ReportClass) As String
  38.  
  39. Dim m_tablesUsedByAReport As String = String.Empty
  40.  
  41. Dim myTables As Tables = report.Database.Tables
  42.  
  43. 'table names in the report'
  44. For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables
  45. m_tablesUsedByAReport = m_tablesUsedByAReport & myTable.Location & ";"
  46. Next
  47. For Each subreport As CrystalDecisions.CrystalReports.Engine.ReportDocument In report.Subreports
  48. For Each mytable As CrystalDecisions.CrystalReports.Engine.Table In subreport.Database.Tables
  49. m_tablesUsedByAReport = m_tablesUsedByAReport & mytable.Location & ";"
  50. Next
  51. Next
  52. Return m_tablesUsedByAReport
  53.  
  54. End Function
Add Comment
Please, Sign In to add comment