Re: DataRelations and DataGrids

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Sijin Joseph (sijinNOSPAMdotnet_at_hotmail.com)
Date: 09/21/04


Date: Tue, 21 Sep 2004 09:25:00 +0530

Hi,

Yes you can use a DataRelation for this purpose, you will need to define
a DataRelation between your parent tables and child tables and then use
the DataColumn.Expression property to set the value to the
ParentRelations relevant field.

This is the relevant documentation from the MSDN documentation of
DataColumn.Expression property

PARENT/CHILD RELATION REFERENCING

A parent table may be referenced in an expression by prepending the
column name with Parent. For example, the Parent.Price references the
parent table's column named Price.

A column in a child table may be referenced in an expression by
prepending the column name with Child. However, because child
relationships may return multiple rows, you must include the reference
to the child column in an aggregate function. For example,
Sum(Child.Price) would return the sum of the column named Price in the
child table.

If a table has more than one child, the syntax is: Child(RelationName).
For example, if a table has two child tables named Customers and Orders,
and the DataRelation object is named Customers2Orders, the reference
would be:

Avg(Child(Customers2Orders).Quantity)

Also check out these articles

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskcreatinglookuptableforlistboxorcomboboxcontrol.asp
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbwlkCreatingLookupTableOnData-BoundWindowsForm.asp

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

aualias wrote:
> I have tables Junk and JunkLookup in a DataSet. Junk has an integer field
> junkType, which is a primary key into JunkLookup.
>
> Can I bind to Junk and use a DataRelation to display and update data in a
> DataGrid?
> Is it better to do a join in the SQL?
>
> Ideally, I would like to copy the database relationships in the DataSet that
> I use on the client.
>
> Thanks.
>
> Alfredo
>
>
>



Relevant Pages

  • Unix Programming FAQ (v1.37)
    ... Why use _exit rather than exit in the child branch of a fork? ... Why doesn't my process get SIGHUP when its parent dies? ... How do I create a named pipe? ... How do I compare strings using regular expressions? ...
    (comp.unix.programmer)
  • Unix Programming FAQ (v1.37)
    ... Why use _exit rather than exit in the child branch of a fork? ... Why doesn't my process get SIGHUP when its parent dies? ... How do I create a named pipe? ... How do I compare strings using regular expressions? ...
    (comp.unix.programmer)
  • Unix Programming FAQ (v1.37)
    ... Why use _exit rather than exit in the child branch of a fork? ... Why doesn't my process get SIGHUP when its parent dies? ... How do I create a named pipe? ... How do I compare strings using regular expressions? ...
    (comp.unix.programmer)
  • Unix Programming FAQ (v1.37)
    ... Why use _exit rather than exit in the child branch of a fork? ... Why doesn't my process get SIGHUP when its parent dies? ... How do I create a named pipe? ... How do I compare strings using regular expressions? ...
    (comp.unix.programmer)
  • Unix Programming FAQ (v1.37)
    ... Why use _exit rather than exit in the child branch of a fork? ... Why doesn't my process get SIGHUP when its parent dies? ... How do I create a named pipe? ... How do I compare strings using regular expressions? ...
    (comp.unix.programmer)