how to avoid duplicate rows in a dataset

liunx

Guest
hi,
i've filled a dataset using 4 data adapters,but all from the same table.Here comes the problem.many duplicate rows appear when they are displayed after binding to a datagrid.
here's a portion of the code.

Function duplicheck()
Dim dr As DataRow
Dim bugid As String
bugid = Nothing
For Each dr In ds1.Tables("form_data").Rows
If dr.Item("bug_id") = bugid Then
ds1.Tables("form_data").Rows.Remove(dr)
bugid = dr.Item("bug_id")
End If
Next
End Function
bug_id is the primary key of form_data.
Please help me survive.

regards,
jithuLets see some code... mostly your sql so we can attempt to helpDISTINCT and GROUP BY will solve the problem.

<!-- w --><a class="postlink" href="http://www.ex-designz.net">www.ex-designz.net</a><!-- w -->
DexterThats not completely true. As an inner join can cause duplicates if the select list is not completely clean.

but that is the basic idea.Originally posted by dexterz
DISTINCT and GROUP BY will solve the problem.

<!-- w --><a class="postlink" href="http://www.ex-designz.net">www.ex-designz.net</a><!-- w -->
Dexter

thanks Dexter,
i've already used(trial & error) dataadapter.MissingSchemaAction = MissingSchemaAction.AddWithKey
Now the problem of duplicates is solved, but a new problem has come.The datagrid is showing the previous selection-row values also whenever a new selection is made.Please help me with this also.

regards,
jithuSounds like your going to have to modify your SQL to handle this correctly.
 
Back
Top