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
:
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
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/
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
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
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