By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,441 Members | 1,831 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,441 IT Pros & Developers. It's quick & easy.

Selecting Dataset records

P: n/a
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
Nov 19 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
No, but this article could help you build one:

http://weblogs.sqlteam.com/davidm/ar...01/21/753.aspx

Essentially, you need to traverse all rows and choose only those that have
distinct column values you are looking for.

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:2F**********************************@microsof t.com...
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

Nov 19 '05 #2

P: n/a
Just realized there is a KB article as well:

http://support.microsoft.com/default...b;en-us;326176

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"Manohar Kamath" <mk*****@TAKETHISOUTkamath.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
No, but this article could help you build one:

http://weblogs.sqlteam.com/davidm/ar...01/21/753.aspx

Essentially, you need to traverse all rows and choose only those that have
distinct column values you are looking for.

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"rodchar" <ro*****@discussions.microsoft.com> wrote in message
news:2F**********************************@microsof t.com...
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


Nov 19 '05 #3

P: n/a
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

Nov 19 '05 #4

P: n/a
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

Nov 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.