Hey I have question about the code. Why use Object as data type for
LastValue? Very new to objects.
Public Function SelectDistinct(ByVal TableName As String, ByVal
SourceTable As DataTable, ByVal FieldName As String) As DataTable
Dim dt As New DataTable(TableName)
dt.Columns.Add(FieldName, SourceTable.Columns(FieldName).DataType)
Dim LastValue As Object = Nothing
Dim dr As DataRow
For Each dr In SourceTable.Select("", FieldName)
If LastValue Is Nothing Or Not ColumnEqual(LastValue,
dr(FieldName)) Then
LastValue = dr(FieldName)
dt.Rows.Add(New Object() {LastValue})
End If
Next dr
If Not (ds Is Nothing) Then
ds.Tables.Add(dt)
End If
Return dt
End Function 'SelectDistinct
"rodchar" wrote:
Thanks everyone for the feedback.
"rodchar" wrote:
Hey all,
Is there a way to get similar functionality as the SELECT DISTINCT records
in a SQL Statement when selecting records from a dataset?
thanks,
rodchar