473,698 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Q: Sorting Relations

Hi

I have two tables to which I have created a one-to-many relationship.

How do I sort the result of the relationship? For example, if one column
contains dates, how do I display in the dates in order in a DataGrid?

Thanks in advance

Geoff
Nov 20 '05 #1
6 1097
Hi Geoff,

Why not select them with as the sort order the dates?

Cor
I have two tables to which I have created a one-to-many relationship.

How do I sort the result of the relationship? For example, if one column
contains dates, how do I display in the dates in order in a DataGrid?

Thanks in advance

Geoff

Nov 20 '05 #2
Hi Cor

Could you give some example code?

Goeff

"Cor Ligthert" <no**********@p lanet.nl> wrote in message
news:uW******** ******@TK2MSFTN GP11.phx.gbl...
Hi Geoff,

Why not select them with as the sort order the dates?

Cor
I have two tables to which I have created a one-to-many relationship.

How do I sort the result of the relationship? For example, if one column
contains dates, how do I display in the dates in order in a DataGrid?

Thanks in advance

Geoff


Nov 20 '05 #3
Hi Geoff

Dim myselectstring as string = "Select * in MyDetailTable order by mydates"

Than your table is sorted not depending the relation, it looks so simple,
where do I understand you wrong?

Maybe you can as well use the dataview I see now, for which I gave you a
sample in that other message, when you are using two datagrids (one master
and one detail)

Cor
Hi Geoff,

Why not select them with as the sort order the dates?

Cor
I have two tables to which I have created a one-to-many relationship.

How do I sort the result of the relationship? For example, if one column contains dates, how do I display in the dates in order in a DataGrid?

Thanks in advance

Geoff



Nov 20 '05 #4
Hi Cor

Yes, I can see what you mean. However, I am dealing with events after the
DataAdaptor. I was trying to do it via a DataTable or DataRow. My
understanding what you could only do a Select etc. during the
DataAdaptor/Connection stage and not once you have a DataTable or DataRow?

Geoff

"Cor Ligthert" <no**********@p lanet.nl> wrote in message
news:OP******** ******@TK2MSFTN GP12.phx.gbl...
Hi Geoff

Dim myselectstring as string = "Select * in MyDetailTable order by mydates"
Than your table is sorted not depending the relation, it looks so simple,
where do I understand you wrong?

Maybe you can as well use the dataview I see now, for which I gave you a
sample in that other message, when you are using two datagrids (one master
and one detail)

Cor
Hi Geoff,

Why not select them with as the sort order the dates?

Cor

> I have two tables to which I have created a one-to-many relationship. >
> How do I sort the result of the relationship? For example, if one column > contains dates, how do I display in the dates in order in a DataGrid? >
> Thanks in advance
>
> Geoff
>
>



Nov 20 '05 #5
Geoff,
Have you tried using a DataViewManager ?

Something like (modified sample from MSDN sample):

' Create a Connection, DataAdapters, and a DataSet.
Dim connection As SqlConnection = New SqlConnection(" Data
Source=localhos t;Integrated Security=SSPI;I nitial Catalog=northwi nd")

Dim customerAdapter As SqlDataAdapter = New SqlDataAdapter( "SELECT
CustomerID, CompanyName FROM Customers", connection)
Dim orderAdapter As SqlDataAdapter = New SqlDataAdapter( "SELECT
OrderID, CustomerID FROM Orders", connection)
Dim orderDetailsAda pter As SqlDataAdapter = New
SqlDataAdapter( "SELECT OrderID, ProductID, Quantity FROM [Order Details]",
connection)

Dim customerDataSet As DataSet = New DataSet

' Open the Connection.
connection.Open ()

' Fill the DataSet with schema information and data.
customerAdapter .MissingSchemaA ction = MissingSchemaAc tion.AddWithKey
orderAdapter.Mi ssingSchemaActi on = MissingSchemaAc tion.AddWithKey
orderDetailsAda pter.MissingSch emaAction =
MissingSchemaAc tion.AddWithKey

customerAdapter .Fill(customerD ataSet, "Customers" )
orderAdapter.Fi ll(customerData Set, "Orders")
orderDetailsAda pter.Fill(custo merDataSet, "OrderDetai ls")

' Close the Connection.
connection.Clos e()

' Create relationships.
customerDataSet .Relations.Add( "CustomerOrders ", _
customerDataSet .Tables("Custom ers").Columns(" CustomerID"), _
customerDataSet .Tables("Orders ").Columns("Cus tomerID"))

customerDataSet .Relations.Add( "OrderDetai ls", _
customerDataSet .Tables("Orders ").Columns("Ord erID"), _
customerDataSet .Tables("OrderD etails").Column s("OrderID"))

' Create default DataView settings.
Dim viewManager As DataViewManager = New
DataViewManager (customerDataSe t)

For Each viewSetting As DataViewSetting In
viewManager.Dat aViewSettings
viewSetting.App lyDefaultSort = True
Next

' Set sort order for each table.
viewManager.Dat aViewSettings(" Customers").Sor t = "CompanyNam e"
viewManager.Dat aViewSettings(" Orders").Sort = "OrderID"
viewManager.Dat aViewSettings(" OrderDetails"). Sort = "ProductID"

' Bind to three DataGrids.
Me.DataGrid1.Se tDataBinding(vi ewManager, "Customers" )
Me.DataGrid2.Se tDataBinding(vi ewManager, "Customers.Cust omerOrders")
Me.DataGrid3.Se tDataBinding(vi ewManager,
"Customers.Cust omerOrders.Orde rDetails")

Note we are binding to a ViewManager instead of the DataSet directly.

Hope this helps
Jay
"Geoff Jones" <ge***@NODAMNSP AM.com> wrote in message
news:40******** *************** @news.dial.pipe x.com...
Hi

I have two tables to which I have created a one-to-many relationship.

How do I sort the result of the relationship? For example, if one column
contains dates, how do I display in the dates in order in a DataGrid?

Thanks in advance

Geoff

Nov 20 '05 #6
Interesting!

Thanks Jay

Geoff

"Jay B. Harlow [MVP - Outlook]" <Ja************ @msn.com> wrote in message
news:eX******** ******@TK2MSFTN GP11.phx.gbl...
Geoff,
Have you tried using a DataViewManager ?

Something like (modified sample from MSDN sample):

' Create a Connection, DataAdapters, and a DataSet.
Dim connection As SqlConnection = New SqlConnection(" Data
Source=localhos t;Integrated Security=SSPI;I nitial Catalog=northwi nd")

Dim customerAdapter As SqlDataAdapter = New SqlDataAdapter( "SELECT
CustomerID, CompanyName FROM Customers", connection)
Dim orderAdapter As SqlDataAdapter = New SqlDataAdapter( "SELECT
OrderID, CustomerID FROM Orders", connection)
Dim orderDetailsAda pter As SqlDataAdapter = New
SqlDataAdapter( "SELECT OrderID, ProductID, Quantity FROM [Order Details]",
connection)

Dim customerDataSet As DataSet = New DataSet

' Open the Connection.
connection.Open ()

' Fill the DataSet with schema information and data.
customerAdapter .MissingSchemaA ction = MissingSchemaAc tion.AddWithKey orderAdapter.Mi ssingSchemaActi on = MissingSchemaAc tion.AddWithKey
orderDetailsAda pter.MissingSch emaAction =
MissingSchemaAc tion.AddWithKey

customerAdapter .Fill(customerD ataSet, "Customers" )
orderAdapter.Fi ll(customerData Set, "Orders")
orderDetailsAda pter.Fill(custo merDataSet, "OrderDetai ls")

' Close the Connection.
connection.Clos e()

' Create relationships.
customerDataSet .Relations.Add( "CustomerOrders ", _
customerDataSet .Tables("Custom ers").Columns(" CustomerID"), _
customerDataSet .Tables("Orders ").Columns("Cus tomerID"))

customerDataSet .Relations.Add( "OrderDetai ls", _
customerDataSet .Tables("Orders ").Columns("Ord erID"), _
customerDataSet .Tables("OrderD etails").Column s("OrderID"))

' Create default DataView settings.
Dim viewManager As DataViewManager = New
DataViewManager (customerDataSe t)

For Each viewSetting As DataViewSetting In
viewManager.Dat aViewSettings
viewSetting.App lyDefaultSort = True
Next

' Set sort order for each table.
viewManager.Dat aViewSettings(" Customers").Sor t = "CompanyNam e"
viewManager.Dat aViewSettings(" Orders").Sort = "OrderID"
viewManager.Dat aViewSettings(" OrderDetails"). Sort = "ProductID"

' Bind to three DataGrids.
Me.DataGrid1.Se tDataBinding(vi ewManager, "Customers" )
Me.DataGrid2.Se tDataBinding(vi ewManager, "Customers.Cust omerOrders") Me.DataGrid3.Se tDataBinding(vi ewManager,
"Customers.Cust omerOrders.Orde rDetails")

Note we are binding to a ViewManager instead of the DataSet directly.

Hope this helps
Jay
"Geoff Jones" <ge***@NODAMNSP AM.com> wrote in message
news:40******** *************** @news.dial.pipe x.com...
Hi

I have two tables to which I have created a one-to-many relationship.

How do I sort the result of the relationship? For example, if one column
contains dates, how do I display in the dates in order in a DataGrid?

Thanks in advance

Geoff


Nov 20 '05 #7

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

Similar topics

2
2134
by: Alvaro G Vicario | last post by:
I have this test code: <html><pre><? echo "Versión: ".phpversion()."\n\n"; $define_list = array( 'PRODUCT_LIST_MODEL' => 0, 'PRODUCT_LIST_NAME' => 0,
11
16373
by: Nikki | last post by:
Is it possible to sort a dataset rather than a dataview? I have a web service that returns a dataset which I would like to sort before returning it (this is so the sorting is standardised and so applications that see the results as xml don't have to fiddle around and sort it themselves later). I have tried sorting a dataview and adding that dataview's table to the dataset but the results don't remain sorted. The only way I can see to do...
2
945
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child datagrid. HTML Datagrid1 TemplateColumn Table Header information Detail Information
4
10033
by: suzy | last post by:
hello. how can i sort data in a dataset? all the examples i have seen on msdn, etc are sorting a dataview. this works fine, but i want to return the results in xml and the dataview doesn't have a .getxml method (unlike the dataset). any ideas? thanks.
1
1798
by: Jef De Rycke | last post by:
Hi access group, I have written code to create relations between tables according to a corresponding relations information table. At first I thought my code was not working properly because after running the code the relations don't show in the relations window. However when I enter data in an underlying table I get referential integrity error messages so the relations does actually exist. The created relations do show in the relations...
8
4146
by: Matthew Curiale | last post by:
I am creating an app that lists clients of a company for management of different attributes for that company. The first page is a listing of the companies currently in the database. I have my repeater working, and paging/sorting works, but there is a small bug that I can't seem to figure out. If, for example, I display 5 records per page, the paging function executes fine, and only shows 5 records per page. This is no problem. When I...
1
5127
by: Randy Fraser | last post by:
How do I create a relationship on muliple columns in an untyped dataset. Why does this not work. da.Fill(ds) ds.Tables(0).TableName = "DesignSummary" ds.Tables(1).TableName = "FormulaSummary" ds.Tables(2).TableName = "MaterialSummary" ds.Tables(3).TableName = "ItemUsage" ds.Tables(5).TableName = "UsageSummary"
2
2871
by: Joe | last post by:
Hi I have a dataset with 3 tables and 2 relations Is there a way to when I am at 1 row to tell if there is a relation on that row ??? I have the code hardcoded but try to make it work if the # of tables and #relations increase or decrease So I can just pass any dataset and walk thru the rows?? Thanks
0
2085
by: rupalirane07 | last post by:
Both grids displays fine. But the problem is only parent datagrid sorting works fine but when i clik on child datagrid for sorting it gives me error: NullReferenceException error Any help........pls urgent ========================================================= <%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm3.aspx.vb" Inherits="TestDatagrids.WebForm3"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">...
0
8680
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
9169
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...
0
9030
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
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,...
1
6528
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
5861
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
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.