cancel
Showing results for 
Search instead for 
Did you mean: 

steps to link a report to web form

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello Md. Mushtaque,

Please post this query to the [.NET Development - Crystal Reports|; forum.

This forum is dedicated to topics related to custom application development or deployment with Crystal Reports in .Net. This includes full versions of Crystal Reports as well as those versions of Crystal Reports bundled with Microsoft Visual Studio .Net.

The forum is monitored by qualified technicians and you will get a faster response there.

Also, all Crystal Reports .NET Development queries remain in one place and thus can be easily searched in one place.

Thanks a lot,

Falk

Former Member
0 Kudos

Hi,

Thanks

As per your instruction I tried to post this question in .NET Development forum but as unable to do so as the limit of 10 question is already over.

Now I am trying to close this question from this forum and post in that one but due to lack of knowledge am unable to close this question from this forum.

Could you please help me to tell me how to close this question?

Thanks and regards

Answers (0)