|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
GetChildRows error - what the f@&# !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 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: Show quoteHide quote > 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 > 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.nl> wrote: Show quoteHide quote > 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 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 Show quoteHide quote > 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. 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: Show quoteHide quote > 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.nl> wrote: >> 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 >
Q: Viewing an excel file
Get Calling Function Info How to set OpenFileDialog to "My Computer" Simple dataset update @ runtime not working How to Transfer an Excel Range to an ADO.Net DataSet or DataTable in VB.Net? Diagnostic Information Collation math.round doesn't work Preferred file locations windows service How to find the window name of a process |
|||||||||||||||||||||||