473,694 Members | 2,751 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create a DataView of Distinct row from a DadaTable

Hi,

I want to know how to create a dataview from a datatable of DISTINCT data.

Thank in advance
Jan 26 '06 #1
3 4363
DataView dv = myDataTable.Def aultView;

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Li Pang" wrote:
Hi,

I want to know how to create a dataview from a datatable of DISTINCT data.

Thank in advance

Jan 26 '06 #2
Peter,

Thanks for your response. But this solution doesn't resolve my problem.
My situation is:
I have a datatable of many rows and I create a dataview by filtering data.
The dataview has somehow multiple identical rows. My question is how to get a
dataview contains ONLY DISTINCT data.

"Peter Bromberg [C# MVP]" wrote:
DataView dv = myDataTable.Def aultView;

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Li Pang" wrote:
Hi,

I want to know how to create a dataview from a datatable of DISTINCT data.

Thank in advance

Jan 27 '06 #3
Well, in this case you have a couple of choices, since your filter doesn't
appear to
provide what you need:

1) sort the rows in some meaningful way so that whatever "Distinct" you need
shows up in consecutive rows, and iterate over the rows comparing each to the
previous one, throwing out any duplicates and possibly using them to populate
a new DataSet / DataView.
2) do this on the server where your SQL query pre-insures that you get what
you need.

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Li Pang" wrote:
Peter,

Thanks for your response. But this solution doesn't resolve my problem.
My situation is:
I have a datatable of many rows and I create a dataview by filtering data.
The dataview has somehow multiple identical rows. My question is how to get a
dataview contains ONLY DISTINCT data.

"Peter Bromberg [C# MVP]" wrote:
DataView dv = myDataTable.Def aultView;

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Li Pang" wrote:
Hi,

I want to know how to create a dataview from a datatable of DISTINCT data.

Thank in advance

Jan 27 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
10893
by: Dianna | last post by:
I don't understand why the dataview or the dataset does not have a 'Select Distinct' option. They both can do so much to filter the data except that. The article Microsoft has 326176 works, but not if you need to select distinct on multiple fields. Does anyone have any suggestions Thanks Diann
2
5828
by: Li Weng | last post by:
Hi, I use a DataView to display a State field. But some rows have the same state like 'OH'. How can I just display only one of them like SQL's DISTINCT? Can I use .rowfilter? How? I don't have to use DataView. If DataTable can do it, it's ok too. Thanks in advance. Li
4
25002
by: luke | last post by:
Hello, I have a dataview that contains about 300k records with 3 cols (read in from a directory). I need to get the count of rows by col1 and col2 (grouping by col1 and col2). What would be the best way to do it? Currently, I am sorting them and reading each row and comparing current row's col1 and col2 with previous row's col1 and col2 and keeping the total in an arraylist. But this is very slow; I am pretty new to C#, any help is...
0
3638
by: Patrick | last post by:
I'm working on a contact management application, and need a hand with one aspect... Here's what I want to create: ------------------------------------ A form split into two parts. There is a datagrid on the left side that lists names and perhaps a couple of other key fields. The user can click on a record in the datagrid, which should automatically pull up details on that record in the various text boxes and other controls on the right...
7
9144
by: Joe | last post by:
Not sure what group this question is better suited for so I sent it to both. I have a DataTable which contains 1545 rows. I have a method that returns a DataTable of distinct rows based on one column. This table ends up with 386 rows. I need to loop through the smaller table and filter a DataView based on each row from this table. This loops takes ~5 secs. Is there anyway to improve this?
8
2249
by: ASP Yaboh | last post by:
I have an ArrayList of data gathered from a database. I want to create a web page from this data by creating a <table>, each cell in each row displays the appropriate data. One of those cells in each row needs a <textarea> control. The background supporting classes are completed, the only task left now is to create the web page. I am at a loss on how to create the table in the page populated by the data. Previously, I would have just...
0
1029
by: amrita | last post by:
hi i have 4 dropdownmenus and m binding them to diff columns of a dataview. want to show only distinct items in the dropdown menu ny filter in dataview to do this thanks in advance amrita
2
18952
by: =?Utf-8?B?cmFuZHkxMjAw?= | last post by:
I have the following line of code (.NET 2.0): myDataView.RowFilter = "SELECT DISTINCT CYCLE_DATE"; where CYCLE_DATE is one of my column names. This throws the following exception: Syntax error: Missing operand after 'DISTINCT' operator. Any suggestions on what this is really trying to tell me?
3
8517
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i have a dataview with a single column in it which contains duplicates. What is the best way to eliminate the duplicates rows so i can turn this column into the primary key? thanks, rodchar
0
8616
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8552
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9107
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8816
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7647
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6479
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5825
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4567
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2248
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.