Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I follow the article of the following link.
http://vb.net-informations.com/crystal-report/vb.net_crystal_report_subreport.htm

But I get an error as the following.
http://i.imgur.com/4MGeOsQ.jpg?1

I followed the steps to linking the the "id" field but it gave me the error.

Here is the code. (database.show(sql) is a function that return a datatable.)
VB
Dim sql As String = "select oid as 'id', time as 'InvoiceDate', invoiceto as 'InvoiceNo', depost2 as 'Discount' from `order` limit 0,3"
Dim dtinv As DataTable = database.show(sql)

sql = "select oid as 'id', productbarcode as 'ItemCode', p.pname as 'ItemName', p.cost as 'Cost', p.dprice as 'UnitPrice', qty as 'Qty', extendedprice as 'TotalAmount' from suborder o left join `product` p on (o.productbarcode = p.pcode) where oid in ("

Dim o As String = ""

For Each row As DataRow In dtinv.Rows
       If o.Length > 0 Then
            o &= " ," & row.Item("id")
       Else
            o &= row.Item("id")
       End If
Next

sql &= o & ")"

Dim dt As DataTable = database.show(sql)

Dim crystalReport As ReportDocument = New ReportDocument()
crystalReport.Load("./SalesOrderReport.rpt")
crystalReport.SetDataSource(dtinv)
crystalReport.Subreports(0).SetDataSource(dt)

CrystalReportViewer1.ReportSource = crystalReport


The "dtinv" table should be as the following.
CSS
id  InvoiceDate         InvoiceNo   Discount
35  2014-12-08 14:36:16 IAN000035   0
36  2014-12-08 14:44:13 IAN000036   0
37  2014-12-08 14:48:35 IAN000037   0


The "dt" table should be as the following.
CSS
id	ItemCode	ItemName	Cost	UnitPrice	Qty	TotalAmount
35	108	Pureness 100 Placenta Mask Sheet Strengthening Ski...	50	100	1	100.00
35	3	Pure Water Baobab Moist Cream	50	100	1	100.00
36	3	Pure Water Baobab Moist Cream	50	100	1	100.00
37	5	Aloe Moistfull Soothing Lotion	50	100	1	100.00


Please help me and give me some advise to solve this problem. Thanks a lot.
Posted
Updated 8-Dec-14 17:50pm
v4
Comments
mudgilsks 8-Dec-14 23:52pm    
where you stuck.
Member 11105424 9-Dec-14 0:04am    
it stuck when the CrystalReportViewer load the report

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900