A
Aziz
Newbie queston here. I am using VB .NET 2003, with an Access 2003
Database and Ole connection in VB.
Assume I have the following tables:
==ORDERS== ==ORDER_PRODUCTS==
OrderID (PK) OrderProductsID (PK)
Field1 OrderID (FK)
Field2 ProductCode (FK from anothertable)
Field3 Field1
etc etc
ORDERS, 1 ---------------- M, ORDER_PRODUCTS
(Linked via OrderID)
I have created the relationship for this in the XML Schema (the XSD
file), let's call it ORDERS_ORDERPRODUCTS
Now what I want to do is create a new order. So I add a new row to
ORDERS and then use my ORDERS DataAdapter to save the changes. But
since the OrderID is a PK autonumber it gets generated automatically.
So how do I know what the OrderID foriegn key is?? I need it to link my
Order and the Product. I suppose I could use:
dsDataset.Orders.Rows(dsTurbobraze.Orders.Rows.Count -
1).Item("OrderID").tostring
to get the auto-generated OrderID of the last added row, but what if
some Orders have been deleted from the DataBase in the past? The
OrderID's woudn't go up nicely in sequence, or would ADO keep a hidden
record of every OrderID, and never use it again?
Basically I just need to return the value of the OrderID autonumber as
it's created.
I posted this in the VB newsgroup and someone recommended using a
GUID(Unique Identifier), but I coudn't find much relevant information
on this. Is there a more straighforward way.
Database and Ole connection in VB.
Assume I have the following tables:
==ORDERS== ==ORDER_PRODUCTS==
OrderID (PK) OrderProductsID (PK)
Field1 OrderID (FK)
Field2 ProductCode (FK from anothertable)
Field3 Field1
etc etc
ORDERS, 1 ---------------- M, ORDER_PRODUCTS
(Linked via OrderID)
I have created the relationship for this in the XML Schema (the XSD
file), let's call it ORDERS_ORDERPRODUCTS
Now what I want to do is create a new order. So I add a new row to
ORDERS and then use my ORDERS DataAdapter to save the changes. But
since the OrderID is a PK autonumber it gets generated automatically.
So how do I know what the OrderID foriegn key is?? I need it to link my
Order and the Product. I suppose I could use:
dsDataset.Orders.Rows(dsTurbobraze.Orders.Rows.Count -
1).Item("OrderID").tostring
to get the auto-generated OrderID of the last added row, but what if
some Orders have been deleted from the DataBase in the past? The
OrderID's woudn't go up nicely in sequence, or would ADO keep a hidden
record of every OrderID, and never use it again?
Basically I just need to return the value of the OrderID autonumber as
it's created.
I posted this in the VB newsgroup and someone recommended using a
GUID(Unique Identifier), but I coudn't find much relevant information
on this. Is there a more straighforward way.