473,434 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,434 software developers and data experts.

Selecting Dataset records

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
4 1919
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Ramesh | last post by:
hi, I am selecting fields from three table for manupulating data and i want to display total number of records selected. But i am always getting -1 value, eventhough 1000 of records are selected....
6
by: aaj | last post by:
Hi all I use a data adapter to read numerous tables in to a dataset. The dataset holds tables which in turn holds full details of the records i.e. keys, extra colums etc.. In some cases I...
2
by: Aaron Ackerman | last post by:
I have been having just on going problems with my MS Datagrids. I have NO idea what I am doing wrong. What is esentially happening is that say I have three records in my Dataset. I click on the...
11
by: Ron L | last post by:
I have a data table that lists a series of items in my database. In my user form, I want the user to be able to filter by a number of criteria (e.g. location, contract, date modified, etc). Other...
6
by: Mike Wilson | last post by:
Dear Group, I have a heirarchical set of database tables, say - "order" and "order_type" and want to display a series of orders in a grid control, and in place of the order_type foreign key...
4
by: =?Utf-8?B?UmljaA==?= | last post by:
Greetings, I have to load 30,000 unique names into a combox. Filling a dataTable takes only a few milliseconds. But populating the combobox and displaying the list takes several seconds - way...
0
by: StefanPienaar | last post by:
Hi Guys Is there any way in c# (or vb.net) to extract a datatable of data from a dataset with multiple datatables which has relationships set up (containing combined data from the datatables)? ...
3
by: =?Utf-8?B?anAybXNmdA==?= | last post by:
In Visual Studio 2005, I have my DataSet filled with several static tables (they might get changed weekly, but that's about it). With one of these tables in the DataSet, is it possible to select...
5
by: hollyquinn | last post by:
Hi I am working with a web application where I am selecting values from a SQL Server 2005 database and then loading the values into different controls on my page. Most of the values load with no...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.