DataRelation on same table ???

M

mathieu

what's wrong with this code?
I get a null Reference exception on the childrelation line.
Can i make a childRelation on the same table. Say for instance link
together all child segment of a parent?


public class DataTableSegment : DataTable
{
public DataTableSegment():base()
{
Columns.AddRange(new DataColumn[]
{
new DataColumn("IdSegment", typeof(System.Int32)),
new DataColumn("IdNiveau", typeof(System.Int32)),
new DataColumn("IdPere", typeof(System.Int32)),
new DataColumn("IdFrere", typeof(System.Int32)),
new DataColumn("Type", typeof(System.Byte)),
new DataColumn("Nom", typeof(System.String)),
}
);

Columns[0].Unique = true;
PrimaryKey = new DataColumn[]{ Columns[0] };

//bug ?? null reference exception
ChildRelations.Add(new DataRelation("parent-child",
this.Columns[0],
this.Columns[2], false));
}
 
D

David Sceppa

Mathieu,

Relations are only supported for DataTables that reside within a
DataSet.

I hope this information proves helpful.

David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2004 Microsoft Corporation. All rights reserved.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top