Home All Groups Group Topic Archive Search About
Author
15 Nov 2005 4:29 PM
Jed
I created a strongly typed dataset using the SQL Server 2005 Express and the
DataSet designer.

I have a many to many relationship among three tables.  The designer created
custom methods on the parent tables which wraps GetChildRows to return the
relationship rows as an array.  I haven't made any changes to the generated
code, but whether I call the custom method or the strongly-typed method the
count is 0 even though I know there should be items there.

Am I missing something in the designer? Am I accessing it properly? Why are
the relationships not being populated?

Any help would be great!

Author
15 Nov 2005 5:25 PM
Miha Markic [MVP C#]
How do you populate the data?
I guess either you don't populate something or your relationships are
wrongly configured.

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/


Show quote
"Jed" <jedatu@newsgroups.nospam> wrote in message
news:AA1669A8-89FD-4FF2-9BBA-DAB4FBF1B0C1@microsoft.com...
>I created a strongly typed dataset using the SQL Server 2005 Express and
>the
> DataSet designer.
>
> I have a many to many relationship among three tables.  The designer
> created
> custom methods on the parent tables which wraps GetChildRows to return the
> relationship rows as an array.  I haven't made any changes to the
> generated
> code, but whether I call the custom method or the strongly-typed method
> the
> count is 0 even though I know there should be items there.
>
> Am I missing something in the designer? Am I accessing it properly? Why
> are
> the relationships not being populated?
>
> Any help would be great!
Author
15 Nov 2005 6:14 PM
Jed
When you drag the tables onto the Schema designer all the standard CRUD sql
gets added.

Here is the designer code that creates the relationship:
this.relationFK_CT_CondoTypeCondo_CT_CondoType = new
System.Data.DataRelation("FK_CT_CondoTypeCondo_CT_CondoType", new
System.Data.DataColumn[] {
                        this.tableCondoType.CondoTypeIDColumn}, new
System.Data.DataColumn[] {
                        this.tableCondoTypeCondo.CondoTypeIDColumn}, false);

Here is the designer code behind the GetChildRows:
[System.Diagnostics.DebuggerNonUserCodeAttribute()]
            public CondoTypeCondoRow[] GetCondoTypeCondoRows() {
                return
((CondoTypeCondoRow[])(base.GetChildRows(this.Table.ChildRelations["FK_CT_CondoTypeCondo_CT_CondoType"])));
            }

In other words, I haven't changed the code that the designer generates. 
Maybe I need to define a query somewhere.  I guess I am clueless here.

(EDIT: topic should be: GetChildRows().Length == 0)


Show quote
"Miha Markic [MVP C#]" wrote:

> How do you populate the data?
> I guess either you don't populate something or your relationships are
> wrongly configured.
>
> --
> Miha Markic [MVP C#]
> RightHand .NET consulting & development www.rthand.com
> Blog: http://cs.rthand.com/blogs/blog_with_righthand/
>
>
> "Jed" <jedatu@newsgroups.nospam> wrote in message
> news:AA1669A8-89FD-4FF2-9BBA-DAB4FBF1B0C1@microsoft.com...
> >I created a strongly typed dataset using the SQL Server 2005 Express and
> >the
> > DataSet designer.
> >
> > I have a many to many relationship among three tables.  The designer
> > created
> > custom methods on the parent tables which wraps GetChildRows to return the
> > relationship rows as an array.  I haven't made any changes to the
> > generated
> > code, but whether I call the custom method or the strongly-typed method
> > the
> > count is 0 even though I know there should be items there.
> >
> > Am I missing something in the designer? Am I accessing it properly? Why
> > are
> > the relationships not being populated?
> >
> > Any help would be great!
>
>
>
Author
16 Nov 2005 4:34 AM
Kevin Yu [MSFT]
Hi,

I think Miha means have you called DataAdapter.Fill to put data into the
typed dataset. Because draging the tables onto schema designer only creates
the datasets structure, but didn't put data into it. You can try to show
the DataSet on a DataGrid to have a test.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
Author
16 Nov 2005 5:52 AM
Jed
ok,  I see what you mean.  When I specified the datasource on my boudn
control the fill code was being added automatically for the parent table but
the table that is the source of the relationship is not being populated.

this.condoTypeTableAdapter.Fill(this.condoTrackerDatabaseDataSet.CondoType);

Does this mean that if I populate the relationship table that the
GetChildRows() on the parent table will suddenly work and be dynamically
filtered by the foreign key?

Show quote
"Kevin Yu [MSFT]" wrote:

> Hi,
>
> I think Miha means have you called DataAdapter.Fill to put data into the
> typed dataset. Because draging the tables onto schema designer only creates
> the datasets structure, but didn't put data into it. You can try to show
> the DataSet on a DataGrid to have a test.
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."
>
>
Author
16 Nov 2005 8:24 AM
Miha Markic [MVP C#]
Hi Jed,

"Jed" <jedatu@newsgroups.nospam> wrote in message
news:F54AB538-9A15-43BA-AA2E-6AC0BCF5CDA8@microsoft.com...
> ok,  I see what you mean.  When I specified the datasource on my boudn
> control the fill code was being added automatically for the parent table
> but
> the table that is the source of the relationship is not being populated.
>
> this.condoTypeTableAdapter.Fill(this.condoTrackerDatabaseDataSet.CondoType);
>
> Does this mean that if I populate the relationship table that the
> GetChildRows() on the parent table will suddenly work and be dynamically
> filtered by the foreign key?

It should.

--
Miha Markic [MVP C#]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/
Author
17 Nov 2005 5:49 AM
Kevin Yu [MSFT]
Yes, I agree.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

AddThis Social Bookmark Button