Selecting Dataset records

Discussion in 'ASP .Net' started by =?Utf-8?B?cm9kY2hhcg==?=, Mar 22, 2005.

  1. 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
     
    =?Utf-8?B?cm9kY2hhcg==?=, Mar 22, 2005
    #1
    1. Advertising

  2. No, but this article could help you build one:

    http://weblogs.sqlteam.com/davidm/archive/2004/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" <> wrote in message
    news:...
    > 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
     
    Manohar Kamath, Mar 22, 2005
    #2
    1. Advertising

  3. Just realized there is a KB article as well:

    http://support.microsoft.com/default.aspx?scid=kb;en-us;326176

    --
    Manohar Kamath
    Editor, .netWire
    www.dotnetwire.com


    "Manohar Kamath" <> wrote in message
    news:%...
    > No, but this article could help you build one:
    >
    > http://weblogs.sqlteam.com/davidm/archive/2004/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" <> wrote in message
    > news:...
    > > 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

    >
    >
     
    Manohar Kamath, Mar 22, 2005
    #3
  4. 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
     
    =?Utf-8?B?cm9kY2hhcg==?=, Mar 22, 2005
    #4
  5. 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
     
    =?Utf-8?B?cm9kY2hhcg==?=, Mar 23, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VB Programmer
    Replies:
    2
    Views:
    432
    Alan Lambert
    Nov 4, 2004
  2. AlecL
    Replies:
    1
    Views:
    354
    Peter Bradley
    Mar 8, 2007
  3. Nathan Sokalski
    Replies:
    5
    Views:
    970
    Paul Clement
    May 10, 2007
  4. David C
    Replies:
    0
    Views:
    328
    David C
    Aug 12, 2008
  5. Mark
    Replies:
    0
    Views:
    124
Loading...

Share This Page