Dear all,

I have tested my code in order to pass single value to single parameter field in crystal report from VB.NET Form, it is ok but the problem is that I want to pass multiple values to only one parameter field called "Product Name" and it displays only one last record.

I want to display like this

Receipt : 0001
Product Name
pencil
pen
stamp
book

Here is my code :

Sub PrintReceipt()
       If conn.State = ConnectionState.Closed Then conn.Open()
       Dim sqlstr As String
       Dim frmchildPOS As FrmPOS =
CType(Application.OpenForms("FrmPOS"), FrmPOS)
       Dim frmchildPrintReceipt As New FrmPrintReceipt
       frmchildPrintReceipt.MdiParent = MdiParent

       sqlstr = "SELECT TblReceiptMaster.ReceiptID,
TblReceiptMaster.ReceiptDate, " & _
       "TblUserAccount.UserName, TblProductList.ProductName, " & _
       "TblReceiptDetail.SaleQTY, TblReceiptDetail.SalePrice,
TblReceiptDetail.Discount FROM TblProductList INNER JOIN
TblReceiptDetail ON TblProductList.ProductID =
TblReceiptDetail.ProductID INNER JOIN TblReceiptMaster ON
TblReceiptDetail.ReceiptID = TblReceiptMaster.ReceiptID INNER JOIN
TblUserAccount ON TblReceiptMaster.EmpID = TblUserAccount.EmpID "

       Dim da As New SqlDataAdapter(sqlstr, conn)
       Dim ds As New DataSet
       da.Fill(ds, "SaleReceipt")

       Dim Rpt As New PrintReceipt

       Dim paramValues As New ParameterValues
       Dim paramDiscreteValue As New ParameterDiscreteValue

       For i As Integer = 0 To ds.Tables("SaleReceipt").Rows.Count - 1
           'find if receiptID in dataset = receiptID in LblReceiptNumber.Text
           If CType(ds.Tables(0).Rows(i).Item(0), Integer) =
CType(frmchildPOS.LblReceiptNumber.Text, Integer) Then
               Rpt.SetParameterValue("receipt",
Format(ds.Tables("SaleReceipt").Rows(i).Item(0), "00000"))
               Rpt.SetParameterValue("datetime",
FormatDateTime(ds.Tables("SaleReceipt").Rows(i).Item(1)))
               Rpt.SetParameterValue("cashier",
ds.Tables("SaleReceipt").Rows(i).Item(2))
               paramDiscreteValue = New ParameterDiscreteValue
               paramDiscreteValue.Value =
ds.Tables("SaleReceipt").Rows(i).Item(3)
               paramValues.Add(paramDiscreteValue)
           End If
       Next

       'pass value to product name field in crystal report
       [B]Rpt.SetParameterValue("productname", (paramValues))[/B]

       'assign report source to crystal report
       frmchildPrintReceipt.CrystalReportViewer1.ReportSource = Rpt

       'print report
       frmchildPrintReceipt.Show()
       conn.Close()
       Rpt = Nothing
   End Sub

I already set parameter field "productname" for allowing to multiple
values, but it is still the same.

Thanks for your helping

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.