Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
There are two tables in my database, SalesInvoiceDetails and SalesInvoicesInventoryRowDetails.

I have 6 x records in my table SalesInvoicesInventoryRowDetails from which Crystal Reports is showing only one (first record).
I checked by putting breakpoints. Dataset is filled with all data but its not appearing in Crystal Report except first record (only one line).
Please need kind help to solve the issue.
Thanks.

What I have tried:

VB
Dim row As DataRow = GridView1.GetDataRow(GridView1.FocusedRowHandle)

    Me.Cursor = Cursors.WaitCursor

    Dim objRpt As New XtraReport1
    Dim ds As New SalesInvoiceDataSet
    Dim adp1 As New SqlClient.SqlDataAdapter("Select * From SalesInvoiceDetails Where InvoiceNo=N'" & row("InvoiceNo") & "'", DAL.OpenSqlConnection)
    adp1.Fill(ds, "SalesInvoiceDetails")

    Dim adp2 As New SqlClient.SqlDataAdapter("Select * From SalesInvoicesInventoryRowDetails Where InvoiceNo=N'" & row("InvoiceNo") & "' order by Sno", DAL.OpenSqlConnection)
    adp2.Fill(ds, "SalesInvoicesInventoryRowDetails")

    DAL.CloseConnection()

    objRpt.DataSource = ds
    Dim s As New SalesInvoicePrintForm
    s.DocumentViewer1.DocumentSource = objRpt
    s.Show()
Posted
Updated 2-Oct-19 15:24pm
v2
Comments
Richard Deeming 30-Sep-19 13:31pm    
Dim adp1 As New SqlClient.SqlDataAdapter("Select * From SalesInvoiceDetails Where InvoiceNo=N'" & row("InvoiceNo") & "'", DAL.OpenSqlConnection)

Don't do it like that!

Your code is vulnerable to SQL Injection[^]. NEVER use string concatenation to build a SQL query. ALWAYS use a parameterized query.

Everything you wanted to know about SQL injection (but were afraid to ask) | Troy Hunt[^]
How can I explain SQL injection without technical jargon? | Information Security Stack Exchange[^]
Query Parameterization Cheat Sheet | OWASP[^]

Dim adp1 As New SqlClient.SqlDataAdapter("Select * From SalesInvoiceDetails Where InvoiceNo=@InvoiceNo", DAL.OpenSqlConnection)
adp1.SelectCommand.Parameters.AddWithValue("@InvoiceNo", row("InvoiceNo"))
adp1.Fill(ds, "SalesInvoiceDetails")

Dim adp2 As New SqlClient.SqlDataAdapter("Select * From SalesInvoicesInventoryRowDetails Where InvoiceNo=@InvoiceNo order by Sno", DAL.OpenSqlConnection)
adp1.SelectCommand.Parameters.AddWithValue("@InvoiceNo", row("InvoiceNo"))
adp2.Fill(ds, "SalesInvoicesInventoryRowDetails")
UCP_2005 30-Sep-19 15:48pm    
Hi Richard, Thanks for replying. I changed the code as you suggested. But still its showing only one record from SalesInvoicesInventoryRowDetails table. I think problem is somewhere in the report as the dataset is filled with the required data in debugged mode.
[no name] 30-Sep-19 20:48pm    
The CR report "definition" differentiates details. None of the code you show is of any use.

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