Skip to Content
avatar image
Former Member

Steps to link a report to Web Application Form. Post Your Opinion

Hi friends,

After going through it what is your opinion. please do post your opinion.

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.vb 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 as the data of report is not getting displayed on the report.

After going through it what is your opinion. please do post your opinion.

While creating the Report has the following Report Options on / checked.

1. Database Server is Case-Incensitive

2. Use Indexes Or Server For Speed

3. Verify on First Refresh

4. Show Preview Panel

5. Display Alerts on Refresh

6. Select Distinct Data for Browsing

Do I have check or uncheck any other option?

Thanks and regards

Edited by: Md. Mushtaque on Sep 6, 2008 2:50 PM

Edited by: Md. Mushtaque on Sep 8, 2008 9:27 AM

Edited by: Md. Mushtaque on Sep 8, 2008 12:14 PM

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Sep 08, 2008 at 11:14 PM

    Hi there,

    A few comments / suggestions:

    1. When posting code using the code tags. When you type your post you can see on the right some tags that you can use. That way your code is easy to distinguish from the rest of your post.

    e.g.

    Some Code Goes here
    

    2. In your code you have this section:

    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
    

    which doesn't seem to be needed to display the report. I suggest that you first get the report displaying before going into anything extra. So please remove this section.

    3. In this section of code:

    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
    

    I would remove the lines:

    myCrystalReportViewer.RefreshReport()
    

    and

    If Session("reportConnectionInfo") IsNot Nothing Then
    

    Just get everything hard-coded first - then you can start adding some if-then statements.

    4. Lastly - you need to be calling this from your Page_Init method. If you are calling it from your page_load method - it may not work.

    Other than that - your code looks ok (given that it is copied directly from one of our samples) - and the options set on your report look fine.

    Regards,

    Shawn

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi,

      The report prompts for database credentials like User id and Password when it tries to get connected to the database and repeats it-self if some connection or tables are lost or dropped. So make sure that the report runs fine from the designer, to be more sure in the Field explorer, right click on the Database fields and go to set datasource location, in the new window create a exact same but new connection, select the fields in "replace with" section with the same table in "Current data source"window, click on Update button, remap the fields if there are any new or unmapped fields.

      Let us know if that helps with answers to the questions asked before.

      Thanks,

      AG.

  • Sep 12, 2008 at 10:51 PM

    If this issue is getting really time-critical for you - you may want to try creating a support case with BO support for some more support.

    I would also recommend trying some sample code since usually samples are in a known working state - you can find some samples to download here:

    https://boc.sdn.sap.com/codesamples

    Shawn

    Add comment
    10|10000 characters needed characters exceeded