How to set data source of sub-reports crystal report using vb.net?
<p>I am new in programming crystal Report, so please help me. i have main report with sub-report on it. i know already how to set data source of main report, the problem is in my sub-report. here's how i did for my main report:</p>

<pre><code>Try
    open_con()
    Dim a As String
    a = "SELECT * FROM students where year_id=1"
    Dim reader As SqlDataReader
    cmd = New SqlCommand(a, dbcon)
    reader = cmd.ExecuteReader

    'tblstud is a datagridview

    While reader.Read
        tblstud.Rows.Add(reader("name"), reader("address"),reader("grade_level"),reader("id_number"))
    End While
    reader.Close()
    cmd.Dispose()
    close_con()
 Catch ex As Exception
    MsgBox(ex.Message)
 End Try

 Dim dtable As New DataTable
 With dtable
     .Columns.Add("name")
     .Columns.Add("address")
     .Columns.Add("g_lvl")
     .Columns.Add("id_num")
 End With
 For Each tblrow As DataGridViewRow In Me.tblstud.Rows
     dtable.Rows.Add(tblrow.Cells("names").Value, tblrow.Cells("addrs").Value, tblrow.Cells("lvl").Value, tblrow.Cells("ids").Value)
 Next

Try
    Dim rptDoc As CrystalDecisions.CrystalReports.Engine.ReportDocument
    rptDoc = New stud_rep
    rptDoc.SetDataSource(dtable)
    CrystalReportViewer1.ReportSource = rptDoc
Catch ex As Exception
    MsgBox(ex.Message)
End Try
</code></pre>

<p>that's how i generated data and set it to the Crystal report, now the problem is in sub-report i don't know how to set data source, i tried to repeat that and set it to the next table (datagridview) and create another datatable but it shows empty.. i tried <code>rptDoc.OpenSubreport(0).SetDataSource(dtable2)</code></p>

<p>hope anybody understand my problem.. thanks in advance</p>