importrow to related table

J

jaYPee

At last I have found the problem why I can't get to work w/ importrow.
The fact is that I'm trying to import data to related table. But after
importing data the foreign is blank. So thats why the record is not
showing in to datagrid.

Anyone know how to work around w/ this problem?

Here's my current code:

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

In my SchYrSemCourseJoin Table I have SchYrSemID field (foreign key)
which is needed. But after using the code above this field is not
filled. I have already setup the correct relationship.

So anyone know if it is possible to fill the SchYrSemID field w/ the
correct key from parent table?
 
C

Cor Ligthert

jaYPee,

Why are you telling all the time about the relationship?
What you are doing here should be easy to debug even without the debugger.
Dim copyRows() As DataRow =
DsStudentCourse1.Tables("Course").Select("CourseCode = 'AUTO 1'")

messagebox.show(copyRows.length.tostring)

When this is zero you know that you have not selected rows.
Dim custTable As DataTable =
DsStudentCourse1.Tables("SchYrSemCourseJoin")

Dim copyRow As DataRow

For Each copyRow In copyRows
custTable.ImportRow(copyRow)
Next
Assuming that the format of "SchYrSemCourseJoin" is exactly the same as
Tables("Course") I see not directly more problems, however when there are no
rows the rest is not done.

Just my thought,

Cor
 
J

jaYPee

Never mind, I have already found the answer. For almost 2 weeks.
hoo...what a waste of time...

Thanks a lot for your reply.
 

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

Top