Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Selecting Dataset records

Reply
Thread Tools

Selecting Dataset records

 
 
=?Utf-8?B?cm9kY2hhcg==?=
Guest
Posts: n/a
 
      03-22-2005
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
 
Reply With Quote
 
 
 
 
Manohar Kamath
Guest
Posts: n/a
 
      03-22-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
 
Manohar Kamath
Guest
Posts: n/a
 
      03-22-2005
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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

>
>



 
Reply With Quote
 
=?Utf-8?B?cm9kY2hhcg==?=
Guest
Posts: n/a
 
      03-22-2005
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

 
Reply With Quote
 
=?Utf-8?B?cm9kY2hhcg==?=
Guest
Posts: n/a
 
      03-23-2005
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting Multiple Records in a GridView David C ASP .Net 0 08-12-2008 06:52 PM
SELECTing only the first n records from a database Nathan Sokalski ASP .Net 5 05-10-2007 12:27 PM
NEWBIE Q:Selecting Distinct records from a datasource AlecL ASP .Net 1 03-08-2007 04:53 PM
Question: Selecting random records from the db (puzzle of the day) VB Programmer ASP .Net 2 11-04-2004 11:30 AM
Selecting no records if condition is true Mark ASP General 0 01-29-2004 06:10 PM



Advertisments