Hi guys,

i am a newbie in crystal report. I having some trouble using subreport. I use the push method to populate the data sourece. The code is as below.

If Session("username") = "" Then
Response.Redirect("~/NoAccess.htm")
Return
End If
cnn.openSql()

If IsPostBack = False Then
Dim dt As DataTable
Dim subdt As DataTable
Dim con As CrystalDecisions.Shared.ConnectionInfo

Dim str As String
Dim i As Integer
i = 0

Dim MainReport As Engine.ReportDocument
Dim Subreport As Engine.ReportDocument
Subreport = New CrystalDecisions.CrystalReports.Engine.ReportDocument()

MainReport = New CrystalDecisions.CrystalReports.Engine.ReportDocument()

MainReport.Load("C:\Project1\Report\MainPart.rpt")


CrystalReportViewer1.ReportSource = MainReport

sql = "SELECT xxx from yyy where xxx=something"
dt = cnn.query(sql)

MainReport.SetDataSource(dt)

sql = "SELECT yyy from xxx where yyy=somethingelse"
subdt = cnn.query(sql)

Subreport.Load("C:\Project1\Report\SubPart.rpt")

MainReport.OpenSubreport("SubPart.rpt")

If subdt.Rows.Count < 0 Then
Else
Subreport.SetDataSource(subdt)
End If

CrystalReportViewer1.DataBind()
CrystalReportViewer1.DisplayToolbar = False
End If

What is wrong? Please advice