Thanks, I knew it would be something like that!
However, if I create a customer object as follows:
Code: Select all
Dim cust As New CUSTOMER
cust.Consultant_ID = 1
cust.Customer_Name = tbCustName.Text
...
odb.CUSTOMERs.InsertOnSubmit(cust)
odb.SubmitChanges()
and then try to use that object in a subsequent insert e.g:
Code: Select all
Dim newDiv As New DIVISION
newDiv.CUSTOMER = cust
newDiv.Name = "APEX"
odb.DIVISIONs.InsertOnSubmit(newDiv)
odb.SubmitChanges()
It throws a "Value of member 'DivisionID' of an object of type 'DIVISION' changed.A member that is computed or generated by the database cannot be changed." error.
If I change it to:
Code: Select all
Dim newDiv As New DIVISION
newDiv.CustomerID = cust.Customer_ID
newDiv.Name = "APEX"
odb.DIVISIONs.InsertOnSubmit(newDiv)
odb.SubmitChanges()
it then works fine. The only way I can set CUSTOMER is if I turn off "Auto Generated Value" on the DivisionID column, it seems to still create the ID from the sequence and refresh the local object. Is this normal?