GetChildRows.Length = 0

G

Guest

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!
 
M

Miha Markic [MVP C#]

How do you populate the data?
I guess either you don't populate something or your relationships are
wrongly configured.
 
G

Guest

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)


Miha Markic said:
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 said:
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!
 
K

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."
 
G

Guest

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?
 
M

Miha Markic [MVP C#]

Hi Jed,

Jed said:
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.
 
K

Kevin Yu [MSFT]

Yes, I agree.

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

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