Re: DataRelation

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Here is a sample that creates a relation on 2 columns ...

ds.Relations.Add("MyRelation",
new DataColumn[]{ds.Tables[0].Columns["x"], ds.Tables[0].Columns["y"]},
new DataColumn[]{ds.Tables[1].Columns["a"], ds.Tables[0].Columns["b"]});


// John Papa
// http://codebetter.com/blogs/john.papa



"Justin Lazanowski" wrote:

> That looks right. The constructor take System.Data.Datacolumn[] parent
> columns.
>
> So then my question would be how do I pass in the parent and child columns?
>
> Forgive me I am very very new at this.
>
> Thanks,
> Justin
>
> "Sahil Malik [MVP]" <contactmethrumyblog@xxxxxxxxxx> wrote in message
> news:%23IIatgDQFHA.3628@xxxxxxxxxxxxxxxxxxxxxxx
> > Look @ the constructor of DataRelation. I think it can take an array of
> > columns. Does that help?
> >
> > - Sahil Malik [MVP]
> > http://codebetter.com/blogs/sahil.malik/
> >
> >
> >
> > "Justin Lazanowski" <justin@xxxxxxxxxxxxxxxxx> wrote in message
> > news:uS4$5XCQFHA.3384@xxxxxxxxxxxxxxxxxxxxxxx
> >> Funny when I did Google this (before I posted to this group) the only
> >> examples I could get are of single field relations which I can handle
> >> just
> >> fine
> >>
> >> In my tables I have Table[1] that has rowid pkey and rectype. I also have
> >> Table[2] that has a rectype, I can add a row ID if I need to the problem
> >> that I have is that Table 1 has fields like this
> >>
> >> Components
> >> Adjustments
> >> Stats
> >>
> >> Table[1] has a parent Table[0] that are related on the row ID
> >>
> >> It has a check date and amount
> >>
> >> So we have Check1 [RowID 1]
> >> Components [RowID 1]
> >> Adjustments [RowID1]
> >> Stats [RowID 1]
> >> Check2 [RowID 2]
> >> Components [RowID 2]
> >> Adjustments [RowID 2]
> >> Stats [RowID2]
> >> ect...
> >> Under each one of the items in Table[1] I need to place the actual data
> >> so
> >> for components it would run a Stored Procedure off a SQL database. The
> >> problem is that I have data that really has no relation. So I added the
> >> rectype Components. The problem of course is that Table[1] has more that
> > one
> >> field called components so there is no unique relation. RowID could be
> > used
> >> but this is again non unique for the group because there are multiple
> >> rowid's in Table[1]. This has lead me to the question of Joining on two
> >> fields instead of one. Joining on RowID and RecType would give me a
> >> unique
> >> value for each record.
> >>
> >> One other note, this DataSet is not a strong typed DataSet. i.e. I am
> >> creating that DS on demand.
> >>
> >> Hopefully this wasn't to long winded for you, I just want to make sure
> >> the
> >> problem is clear so that I can get the proper response.
> >>
> >> Also, is this just a silly way to do what I am doing? I am really not
> > trying
> >> to make more work for myself.
> >>
> >> Thanks for you help!
> >>
> >> Justin
> >> "W.G. Ryan eMVP" <WilliamRyan@xxxxxxxxx> wrote in message
> >> news:%23H$isj6PFHA.2252@xxxxxxxxxxxxxxxxxxxxxxx
> >> > Yes, if they are of the same type. A datarelation is the perfect way
> >> > to
> >> > pull it off... are you familiar w/ it? If not I can point you to some
> >> > examples (although Googling on DataRelation is probably the best way to
> >> > go).
> >> >
> >> > --
> >> > W.G. Ryan, MVP
> >> >
> >> > www.tibasolutions.com | www.devbuzz.com | www.knowdotnet.com
> >> > "Justin Lazanowski" <justin@xxxxxxxxxxxxxxxxx> wrote in message
> >> > news:ObdoN85PFHA.244@xxxxxxxxxxxxxxxxxxxxxxx
> >> >>
> >> >>
> >> >> I have some data that is disassociated, I am trying to put an ad-hoc
> >> >> relationship into it so that I can get it hierarchical.
> >> >>
> >> >> What I need to do is create a relationship on two fields in a table.
> >> >> Is
> >> >> it
> >> >> possible to do this?
> >> >>
> >> >> Thanks,
> >> >>
> >> >> Justin
> >> >>
> >> >>
> >> >
> >> >
> >>
> >>
> >
> >
>
>
>
.



Relevant Pages

  • Re: MDI Child Forms -- Diffrent Behavior in new Framework
    ... Justin, ... Dim frmBrowse As New Form1 ... Dim MDIClient As System.Windows.Forms.Control ... > from the Parent, I set it's DockStyle to fill, I also have the child form ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: DataRelation
    ... The constructor take System.Data.Datacolumnparent ... RowID could be ... >>> Justin ...
    (microsoft.public.dotnet.framework.adonet)
  • pci 0000:01:00.0: BAR 6: no parent found for of device [0xfffe0000-0xffffffff]
    ... (just pulled the latest git) ... (BAR 6: no parent found for of device) ... Justin P. Mattock ...
    (Linux-Kernel)
  • Re: DataRelation
    ... So then my question would be how do I pass in the parent and child columns? ... RowID could be ... this DataSet is not a strong typed DataSet. ... >>> examples (although Googling on DataRelation is probably the best way to ...
    (microsoft.public.dotnet.framework.adonet)