Dear sir, I'm evaluating ES2008 and found a strange behaviour with databinding.
Suppose I have 2 tables
Order: OrderID, OrderDate
OrderDetail: OrderID, Product
Order.OrderID <->> OrderDetail.OrderID relationship
OrderID is not an AutoNumber/Identity so I must supply it in code.
Code1: This works perfectly
Code:
dim o as new Order()
o.OrderID = 1
o.OrderDate = #01/01/2008#
dim od as OrderDetail()
od = o.OrderDetailCollectionByOrderID.AddNew()
od.Product = "XYZ"
o.Save()
Code2: This code does not work
Code:
dim o_coll as new OrderCollection
dim o as Order()
dim od as OrderDetail()
dim bs as new bindingsource
bs.datasource=o_coll
o = bs.AddNew()
o.OrderID = 1
o.OrderDate = #01/01/2008#
bs.ResetBindings(false)
od = ctype(bs.current, OrderDetail).OrderDetailCollectionByOrderID.AddNew()
od.Product = "XYZ"
o_coll.Save()
In Code2, the field value of od.OrderID is nothing so I receive error when trying to save.
I don't know why it is not automatically filled with o.OrderID value. Do I missing something here?
Regards,
Lewi