473,396 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

GetChildRows error - what the f@&# !

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
4 1777
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Ben R. | last post by:
Could someone fill me in on the difference between the following three DataRow methods: GetParentRow GetParentRows GetChildRows I'm guessing the difference between the first two is that one...
13
by: deko | last post by:
I use this convention frequently: Exit_Here: Exit Sub HandleErr: Select Case Err.Number Case 3163 Resume Next Case 3376 Resume Next
9
by: Christopher Weaver | last post by:
I've writtten the following (which compiles and runs). For some reason, TaskRows is always empty. DataRow TaskRows; foreach(DataRow TaskRow in dsTaskActivities.Tables.Rows) { TaskRows =...
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
2
by: G .Net | last post by:
Hi A question has just occurred to me. I can get the child rows in a relationship using GetChildRows. Further, I can do something like: For Each child As DataRow In...
1
by: delusion7 | last post by:
I'm really lost right now, I can't figure out how to pass to values from a table back to the presentationTier. I am searching by the value selected in the parent(carSize) using a comboBox and passing...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.