473,386 Members | 1,803 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,386 software developers and data experts.

Sorting a Strong Typed Dataset

Hi, I am looking for a way to sort a strong typed dataset. It would seem the most straightforward way is to use a dataview. The only problem is when I use the dataview I seem to loose the strong typed properties from my original dataset

Anyone that can point me to an example of how to sort my dataset and maintain the use of my typed properties would be greatly appreciated

Thank,
Freeon
Nov 22 '05 #1
3 2723
Cor
Hi Freeon,

By using a dataview you are not sorting the dataset.

As it said, it is a view on the data from the dataset.

You also can use a rowfilter and that is exact what it says, a filter.

But if the problem is different tell it?

Cor
Nov 22 '05 #2
Right, I can use the .sort property change the order rows are accessed in the dataview. This works great but I loose the Strong Typed Names from the original dataset (unless I'm missing something) when I use the dataview

'************************
'Here is a quick sample (Unsorted)
Dim drHeader As CUnit.HeaderRo
Dim objUnits As New CUnit(ConnectionString) 'This is a Strong Typed Dataset (.xsd
objUnits.Loa

For Each drHeader In objUnits.Heade
Writeline drHeader.LK_I
Nex

'************************
'Now Here is the sorted example where I loose Strong Typed Properties from the Unit Datase
Dim drHeader As DataRowVie
Dim objUnits As New CUnit(ConnectionString) 'This is a Strong Typed Dataset (.xsd
objUnits.Loa

Dim dvHeader as New DataView(objUnits.Header
dvHeader.Sort = "LK_id desc

For Each drHeader In dvHeade
Writeline drHeader("LK_ID") 'This works but I lost the ability to use the typed property name (LK_ID)
Nex
'************************

The second example is 90% of what I want to do.

Just incase the 10% is not so clear this is how you access a non-typed datase
Writeline drHeader("LK_ID"
and this is how you access a typed dataset
Writeline drHeader.LK_I

I can't figure out how to sort a dataset while maintaining the typed property names. Usually I would not care, but I have allot of class' that need to be sorted a second way and don't want to rewrite all the UI translation code

Thanks in advance
Freeo

----- Cor wrote: ----

Hi Freeon

By using a dataview you are not sorting the dataset

As it said, it is a view on the data from the dataset

You also can use a rowfilter and that is exact what it says, a filter

But if the problem is different tell it

Co

Nov 22 '05 #3
Cor
Hi Freeon,

I have seen you have posted this to a lot of groups, so I do not know if you
have your answer.

The typed dataset is mostly (when we see it in this newsgroup) an
automaticly by Microsoft as a wizard build dataset.

I never saw that as a wizard for the dataview.

There should be posibilities to make your own strongly typed dataview.

Than you can do when you do it right instead of dv("myItem"), dv.myItem.

That is not something I would spent much time on.

(There are of course more posibilities using the binding context from the
dataset, but that is also something that if I need the syntax above I would
not spent to much time for)

Just my thought,

Cor

"Freeon" <an*******@discussions.microsoft.com> schreef in bericht
news:E1**********************************@microsof t.com...
Right, I can use the .sort property change the order rows are accessed in the dataview. This works great but I loose the Strong Typed Names from the
original dataset (unless I'm missing something) when I use the dataview.
'*************************
'Here is a quick sample (Unsorted):
Dim drHeader As CUnit.HeaderRow
Dim objUnits As New CUnit(ConnectionString) 'This is a Strong Typed Dataset (.xsd) objUnits.Load

For Each drHeader In objUnits.Header
Writeline drHeader.LK_ID
Next

'*************************
'Now Here is the sorted example where I loose Strong Typed Properties from the Unit Dataset Dim drHeader As DataRowView
Dim objUnits As New CUnit(ConnectionString) 'This is a Strong Typed Dataset (.xsd) objUnits.Load

Dim dvHeader as New DataView(objUnits.Header)
dvHeader.Sort = "LK_id desc"

For Each drHeader In dvHeader
Writeline drHeader("LK_ID") 'This works but I lost the ability to use the typed property name (LK_ID). Next
'*************************

The second example is 90% of what I want to do.

Just incase the 10% is not so clear this is how you access a non-typed dataset Writeline drHeader("LK_ID")
and this is how you access a typed dataset:
Writeline drHeader.LK_ID
I can't figure out how to sort a dataset while maintaining the typed property names. Usually I would not care, but I have allot of class' that
need to be sorted a second way and don't want to rewrite all the UI
translation code.
Thanks in advance,
Freeon

----- Cor wrote: -----

Hi Freeon,

By using a dataview you are not sorting the dataset.

As it said, it is a view on the data from the dataset.

You also can use a rowfilter and that is exact what it says, a filter.
But if the problem is different tell it?

Cor

Nov 22 '05 #4

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

Similar topics

3
by: Alex Ayzin | last post by:
Hi, I have a column in my WinGrid, that's being populated with numeric data, but it's of String datatype(business rule requires to have these numbers as varchars in DB). On top of that, I need...
2
by: Freeon | last post by:
Hi, I am looking for a way to sort a strong typed dataset. It would seem the most straightforward way is to use a dataview. The only problem is when I use the dataview I seem to loose the strong...
3
by: paul.phillips | last post by:
Hi I have the following table (*=Primary Key): tblNews: fldID (Indentity) fldSite int * fldPageID int * fldSection int * fldContent
4
by: Richard | last post by:
When i try sorting in the database, it sorts the numbers: 0 1 102 2 304 305 4 etc....
3
by: Chris Thunell | last post by:
I have 2 forms, on 1 form i use the wizards to create a strong typed dataset with tables from an SQL database... and from that i can do stuff like: me.daEmployee.fill(me.dataset11.tblEmployee) ...
3
by: Steve Amey | last post by:
Hi all I have created a strong DataSet using Visual Studio. I have been in to the DataSet's vb file to have a look at the code and see if I can add things to it. What I'm after is to create a...
1
by: Steve | last post by:
I have a windows CE application, talking to a C# WebService. In the WebService project I have created a dataset (dsJobList), and there is a web method in there which returns a fully loaded...
4
by: Jon Paal | last post by:
I am passing an xml data file to a server control and need to sort the data. The data has three levels(tables). What is the recommended approach to do the sorting ? (using vb.net and asp.net...
7
by: Peter Kirk | last post by:
Hi say I have a list of Person objects, which I want to sort. But I don't just want to sort by "name" say, but by several fields in the Person object. Maybe 1st priority by height, 2nd priority...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...

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.