ImportRow does not work w/ grand child relation

  • Thread starter Thread starter jaYPee
  • Start date Start date
J

jaYPee

I have tried almost everything I know but still I can't find a way on
how to resolve this problem.

I'm using ImportRow to copy some record from 1 table to another table.
Here are my code that doesn't work:

Dim copyRows() As DataRow =
DsStudentCourse1.Tables("Course").Select("CourseCode = 'AUTO 1'")

Dim custTable As DataTable =
DsStudentCourse1.Tables("SchYrSemCourseJoin")

Dim copyRow As DataRow

For Each copyRow In copyRows
custTable.ImportRow(copyRow)
Next

Me.DataGrid2.DataSource = DsStudentCourse1
Me.DataGrid2.DataMember =
"Students.StudentsSchYrSem.SchYrSemSchYrSemCourseJoin"

My problem here I think is in the DataGrid2.DataMember. Because if I
changed it w/ "SchYrSemCourseJoin" (which is the name of the
grandchild table) the code works fine. But of course I can't use it
since ""SchYrSemCourseJoin" is related from SchYrSem Table.

Here's the scenario.
I have three tables:
Students Table
SchYrSem Table
SchYrSemCourseJoin Table

SchYrSem is related from Students Table
SchYrSemCourseJoin is related from SchYrSem Table

The relation name of Students and SchYrSem is "StudentsSchYrSem"
The relation name of SchYrSem and SchYrSemCourseJoin is
"SchYrSemSchYrSemCourseJoin"

So therefore in order to view the related records of SchYrSem the
datamember of datagrid2 is
"Students.StudentsSchYrSem.SchYrSemSchYrSemCourseJoin"
 
jaYPee,

To use importrow, you need to have a seperate identical table. (can be in
the same dataset).

That you get with
dim mytable as new datatable = myoldtable.clone

Did you do something like this, I do not see that in your code.

I hope this helps something?

Cor
 
Not neccessarily I have to use the clone method since I'm using the
existing table.

Dim custTable As DataTable =
DsStudentCourse1.Tables("SchYrSemCourseJoin")
 
Back
Top