Adapter.Update() problem with Access Database relationship

D

divisortheory

I have two tables. First table is like this:

TABLE PrimaryTable
----Guid PrimaryID (Primary Key)
----string PrimaryName
----int PrimaryValue

Second table is like this:

TABLE SecondaryTable
----Guid SecondaryID
----Guid PrimaryID


There is a relationship defined between PrimaryTable.PrimaryID and
SecondaryTable.PrimaryID, and Enforce Referential Integrity is set to
true (downward and upward cascading are both set to false)

I insert a row into PrimaryTable, then a row into SecondaryTable with
the same Guid as in the PrimaryTable. In this row, PrimaryValue = 1.

Later, I get the row from PrimaryTable and set PrimaryValue to 2. When
I perform my update, I get this error:

"The record cannot be deleted or changed because table 'SecondaryTable'
includes related records."

Comparing the debugger and the live database side by side, I've
confirmed that the live database's view and the DataRow's modified view
differs only in the value of PrimaryValue.

Why should this fail, and how can I fix it without turning off
referential integrity checking? It's seems like a legitimate update to
me.
 
R

RobinS

You have to set the cascade changes to True (at least from
top to bottom) if you want to change a field in the parent
record that is related to a field in the child records.

Robin S.
 

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