Click here to Skip to main content
15,881,424 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
 Form2.CrystalReportViewer1.ReportSource = Nothing
        Form2.CrystalReportViewer1.Refresh()
        Dim obj As mydataset = New mydataset
If presentdaybal > 0 Then 'NOTE:if balance > 0 then only this condition satisfies
                        Dim balrow As DataRow = obj.Tables("BAL_REG").NewRow()
                        balrow("facno") = facno
                        balrow("fname") = fname
                        balrow("fbalance") = presentdaybal
                        balrow("fglhead") = fglhead
                        obj.Tables("BAL_REG").Rows.Add(balrow)
                    End If
                Loop
                dr.Close()
            End If

            Dim db As New SqlDataAdapter(cmd1)
            db.Fill(obj, "BAL_REG")
            Form2.Show()
            Dim cr As New ReportDocument
            cr = New Balance_Report
            cr.SetDataSource(obj.Tables("BAL_REG"))
            obj.Reset()
            Form2.CrystalReportViewer1.ReportSource = cr
my out puts are:-

accno name balance
00001 xyz 9000
00002 abc 8000
00002 8000 //garbage value or duplicate value how to remove this ..?
and checked by putting 'distinct' in query no changes
Posted
Updated 2-Dec-14 2:02am
v4
Comments
Sinisa Hajnal 2-Dec-14 7:43am    
Exclude them from the query so they never get into the dataset? We don't see how you get the data, from where and why would THAT line be garbage instead of the one above it.
lakshjoshi 2-Dec-14 7:51am    
please look at my updated data....
Sinisa Hajnal 2-Dec-14 8:32am    
Again, you're not showing any problem. By your own condition, balance is > 0 so second 0002 row is valid.
lakshjoshi 2-Dec-14 8:35am    
thats the thing in loop only two times iteration hapening but while displaying its making problem i debug that one their its happening only two iteration then where that third line coming from?
Sinisa Hajnal 2-Dec-14 8:38am    
I see Loop command, but not the beginning of the loop. Anyhow, check my solution, see if anything of that helps.

If you're not selecting from the database, but adding like this, then you have to use RowFilter and Select. RowFilter to exclude those rows that don't have balance like this:

yourTable.RowFilter = "balance > 0"
You then use yourTable.DefaultView to get only filtered rows.

As for select: before creating / adding new row, do the following:
VB
Dim rows() as DataRow = obj.Tables("BAL_REG").Select("accno = " + facno, "")
if rows.Lenght > 0 
    ' you have a duplicate number!
end if


Also, in your code above, you're always creating new dataset which should have empty tables so how can you have duplicates?


If this helps please take time to accept the solution. Thank you.
 
Share this answer
 
Comments
lakshjoshi 2-Dec-14 8:50am    
i want to make you clear,i am facing problem with crystal report that when i checked their is no indication that duplicate items filling in to dataset but while displaying its copying its previous value.
its problem with my filling i am filling double time to crystall report so its showing like that...thank you solved...
 
Share this answer
 

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