Recursive relationship in ADO .NET dataset

D

Dan

Hi to all

I have a data set "dsTest" with one table "Sample" having next fields:

ID1 int (primary key)
Name string
ID2 int.

I created a recursive relationship between ID1 and ID2, named "SampleRel".
The problem is the depth of relationship.
This relationship results in next possible binding for my grids:

Sample -|
| - SampleRel -|
|- SampleRel -|
|- . . .

How can I restrict the depth of this relationship to only one "child table"?

Sample -|
| - SampleRel

This is a simplified sample of my problem. In my application table that have
self relation is also in relation with other tables.
When I create an instance of the data set I receive this error:
"An unhandled exception of type 'System.StackOverflowException' occurred in
system.windows.forms.dll"

Thank you !

Dan
 
S

Sahil Malik

Dan .. in one short answer - You can't.

You are specifying a relationship, like a foreignkey - just as in the
database you can't say that this self referencing foreign key is only 1
level deep, you can't do that in datasets either.

What you could do very easily though is, set the relation, and do a
GetChldRows(), and then bind the resulting datarow array with your datagrid.
That won't give you the stackoverflow exception. Alternatively as a second
choice, you could use dataviews.

:)

- Sahil Malik
http://codebetter.com/blogs/sahil.malik/
 
D

Dan

Thank you !

I searched for something equivalent to sql:max-depth in SQLXML 3.0 but
without success.

I'll try another approach to avoid this problem.
 
D

Dan

Thank you !

I searched for something equivalent to sql:max-depth in SQLXML 3.0 but
without success.

I'll try another approach to avoid this problem.

Dan
 
D

Dan

Thank you !

I searched for something equivalent to sql:max-depth in SQLXML 3.0 but
without success.

I'll try another approach to avoid this problem.

Dan
 

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