Re: DataRelation
- From: John Papa <JohnPapa@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 13 Apr 2005 09:35:02 -0700
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
> >> >>
> >> >>
> >> >
> >> >
> >>
> >>
> >
> >
>
>
>
.
- Follow-Ups:
- Re: DataRelation
- From: Justin Lazanowski
- Re: DataRelation
- References:
- DataRelation
- From: Justin Lazanowski
- Re: DataRelation
- From: W.G. Ryan eMVP
- Re: DataRelation
- From: Justin Lazanowski
- Re: DataRelation
- From: Sahil Malik [MVP]
- Re: DataRelation
- From: Justin Lazanowski
- DataRelation
- Prev by Date: Re: Extract Unique Values from Database
- Next by Date: Re: Can't Read Excel File (OleDb) w/ ASP.NET Impersonation
- Previous by thread: Re: DataRelation
- Next by thread: Re: DataRelation
- Index(es):
Relevant Pages
|