Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

steps to link a report to web form

Hi friends,

Could any one give the complete steps of Linking a report to web form so that when called / clicked the link the report can display the data.

I have unchecked the "Report Option -> Save Data with Reports". So that the report could not take extra space.

I have DB connection code in my .aspx file, it is as follows:

Private Sub ConfigureCrystalReports()

Dim fileName As String = "Reports\" & ReportID & ".rpt"

Dim reportPath As String = Server.MapPath(fileName)

myRepDoc = New ReportDocument()

myRepDoc.Load(reportPath)

myCrystalReportViewer.ReportSource = myRepDoc

'myCrystalReportViewer.RefreshReport()

Dim myConnectionInfo As ConnectionInfo = New ConnectionInfo()

If Session("reportConnectionInfo") IsNot Nothing Then

Dim ConnInforArrList As ArrayList = DirectCast(Session("reportConnectionInfo"), ArrayList)

myConnectionInfo.ServerName = ConnInforArrList(0)

myConnectionInfo.DatabaseName = ConnInforArrList(1)

myConnectionInfo.UserID = ConnInforArrList(2)

myConnectionInfo.Password = ConnInforArrList(3)

Else

lblMessage.ForeColor = Drawing.Color.Red

lblMessage.Text = "Session is off. Please Relogin to See the Report."

End If

SetDBLogonForReport(myConnectionInfo, myRepDoc)

SetDBLogonForSubreports(myConnectionInfo, myRepDoc)

myCrystalReportViewer.SelectionFormula = GetFieldName(ReportID) & "='" & Session("CompCode") & "'"

myCrystalReportViewer.Visible = True

End Sub

Private Sub SetDBLogonForReport(ByVal myConnectionInfo As ConnectionInfo, ByVal myReportDocument As ReportDocument)

Dim myTables As Tables = myReportDocument.Database.Tables

For Each myTable As CrystalDecisions.CrystalReports.Engine.Table In myTables

Dim myTableLogonInfo As TableLogOnInfo = myTable.LogOnInfo

myTableLogonInfo.ConnectionInfo = myConnectionInfo

myTable.ApplyLogOnInfo(myTableLogonInfo)

Next

End Sub

Private Sub SetDBLogonForSubreports(ByVal myConnectionInfo As ConnectionInfo, ByVal myReportDocument As ReportDocument)

Dim mySections As Sections = myReportDocument.ReportDefinition.Sections

For Each mySection As Section In mySections

Dim myReportObjects As ReportObjects = mySection.ReportObjects

For Each myReportObject As ReportObject In myReportObjects

If myReportObject.Kind = ReportObjectKind.SubreportObject Then

Dim mySubreportObject As SubreportObject = CType(myReportObject, SubreportObject)

Dim subReportDocument As ReportDocument = mySubreportObject.OpenSubreport(mySubreportObject.SubreportName)

SetDBLogonForReport(myConnectionInfo, subReportDocument)

If myReportObject.Name = "Subreport1" Then

Dim lvSec As Section = subReportDocument.ReportDefinition.Sections("DetailSection1")

If Not lvSec Is Nothing Then

Dim t1 As TextObject

t1 = lvSec.ReportObjects("txtEmpName")

t1.Text = Session.Contents("EmpName")

Dim t2 As TextObject

t2 = lvSec.ReportObjects("txtRepID")

t2.Text = Request.QueryString("REPID")

End If

End If

End If

Next

Next

End Sub

Please do help me out.

Thanks and regards

Former Member

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question