ImportRow does not work w/ grand child relation

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"
 
C

Cor Ligthert

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
 
J

jaYPee

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

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

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

Similar Threads


Top