By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,534 Members | 950 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,534 IT Pros & Developers. It's quick & easy.

GetChildRows error - what the f@&# !

P: n/a
What's wrong with this code?

1 Dim parentRow, childRow as DataRow
2
3 For i = 0 To mainDataTable.Rows.Count - 1
4 parentRow = mainDataTable.Rows(i)
5 childRow = parentRow.GetChildRows("DataRelation")
6 mainDataTable.Rows(i).Item("Column1") = childRow.Item("Column1")
7 next i

mainDataTable is a plain old DataTable already instantiated.
DataRelation is the name of a valid DataRelation object in the DataSet
that joins these two tables.

I get this error at line 5:

"Value of type '1-dimensional array of System.Data.DataRow' cannot be
converted to 'System.Data.DataRow'.

What conversion is it talking about? I'm loading a DataRow object with
a DataRow object!!!

Any help is greatly appreciated,
Daniel

Nov 2 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
I, and I think a lot of other posters in this form, would like it if you
wouldn't hide your own incompetence with bad words.

Your problem is quite simple; you are assigning an array of rows
(parentRow.GetChildRows("DataRelation")) to a row.
And that's not possible.

Daniel wrote:
What's wrong with this code?

1 Dim parentRow, childRow as DataRow
2
3 For i = 0 To mainDataTable.Rows.Count - 1
4 parentRow = mainDataTable.Rows(i)
5 childRow = parentRow.GetChildRows("DataRelation")
6 mainDataTable.Rows(i).Item("Column1") = childRow.Item("Column1")
7 next i

mainDataTable is a plain old DataTable already instantiated.
DataRelation is the name of a valid DataRelation object in the DataSet
that joins these two tables.

I get this error at line 5:

"Value of type '1-dimensional array of System.Data.DataRow' cannot be
converted to 'System.Data.DataRow'.

What conversion is it talking about? I'm loading a DataRow object with
a DataRow object!!!

Any help is greatly appreciated,
Daniel
Nov 2 '06 #2

P: n/a
Oh good grief. Well thanks for your answer, but I can do without the
moral correction, especially since I'm not hiding incompetence. I'm
throwing my FRUSTRATION and CONFUSION right out there for all to see.
And I didn't say any "bad words". Hope you didn't melt or turn into a
pumpkin or something after reading such atrocious language, er,
symbols.

For your information, my confusion was in the fact that my code almost
exactly matches the code Microsoft uses in the help file for the
GetChildRows method (see excerpt below):

Dim instance As DataRow
Dim relation As DataRelation
Dim returnValue As DataRow()

returnValue = instance.GetChildRows(relation)
They don't show that GetChildRows requires an index after the call. I
found that though by searching more closely in the example they give
farther down the page. So thanks for helping me, and also making me a
holier person.


On Nov 2, 11:33 am, Theo Verweij <tverw...@xs4all.nlwrote:
I, and I think a lot of other posters in this form, would like it if you
wouldn't hide your own incompetence with bad words.

Your problem is quite simple; you are assigning an array of rows
(parentRow.GetChildRows("DataRelation")) to a row.
And that's not possible.

Daniel wrote:
What's wrong with this code?
1 Dim parentRow, childRow as DataRow
2
3 For i = 0 To mainDataTable.Rows.Count - 1
4 parentRow = mainDataTable.Rows(i)
5 childRow = parentRow.GetChildRows("DataRelation")
6 mainDataTable.Rows(i).Item("Column1") = childRow.Item("Column1")
7 next i
mainDataTable is a plain old DataTable already instantiated.
DataRelation is the name of a valid DataRelation object in the DataSet
that joins these two tables.
I get this error at line 5:
"Value of type '1-dimensional array of System.Data.DataRow' cannot be
converted to 'System.Data.DataRow'.
What conversion is it talking about? I'm loading a DataRow object with
a DataRow object!!!
Any help is greatly appreciated,
Daniel
Nov 2 '06 #3

P: n/a
Frankly, I don't even know why you had to say "what the form" (or mask it
with punctuation) when your question wasn't about Windows Forms at all. ;-)

-----
Tim Patrick
Start-to-Finish Visual Basic 2005
Oh good grief. Well thanks for your answer, but I can do without the
moral correction, especially since I'm not hiding incompetence. I'm
throwing my FRUSTRATION and CONFUSION right out there for all to see.
And I didn't say any "bad words". Hope you didn't melt or turn into a
pumpkin or something after reading such atrocious language, er,
symbols.

Nov 2 '06 #4

P: n/a
And you still don't see the error in your own code; the ms code is
correct and your code is (like you said) almost like it (except for the
bug in your code).

Daniel wrote:
Oh good grief. Well thanks for your answer, but I can do without the
moral correction, especially since I'm not hiding incompetence. I'm
throwing my FRUSTRATION and CONFUSION right out there for all to see.
And I didn't say any "bad words". Hope you didn't melt or turn into a
pumpkin or something after reading such atrocious language, er,
symbols.

For your information, my confusion was in the fact that my code almost
exactly matches the code Microsoft uses in the help file for the
GetChildRows method (see excerpt below):

Dim instance As DataRow
Dim relation As DataRelation
Dim returnValue As DataRow()

returnValue = instance.GetChildRows(relation)
They don't show that GetChildRows requires an index after the call. I
found that though by searching more closely in the example they give
farther down the page. So thanks for helping me, and also making me a
holier person.


On Nov 2, 11:33 am, Theo Verweij <tverw...@xs4all.nlwrote:
>I, and I think a lot of other posters in this form, would like it if you
wouldn't hide your own incompetence with bad words.

Your problem is quite simple; you are assigning an array of rows
(parentRow.GetChildRows("DataRelation")) to a row.
And that's not possible.

Daniel wrote:
>>What's wrong with this code?
1 Dim parentRow, childRow as DataRow
2
3 For i = 0 To mainDataTable.Rows.Count - 1
4 parentRow = mainDataTable.Rows(i)
5 childRow = parentRow.GetChildRows("DataRelation")
6 mainDataTable.Rows(i).Item("Column1") = childRow.Item("Column1")
7 next i
mainDataTable is a plain old DataTable already instantiated.
DataRelation is the name of a valid DataRelation object in the DataSet
that joins these two tables.
I get this error at line 5:
"Value of type '1-dimensional array of System.Data.DataRow' cannot be
converted to 'System.Data.DataRow'.
What conversion is it talking about? I'm loading a DataRow object with
a DataRow object!!!
Any help is greatly appreciated,
Daniel
Nov 2 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.