Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Parent and Child objects and foreign keys
Message
De
24/01/2007 04:09:12
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Titre:
Parent and Child objects and foreign keys
Versions des environnements
Environment:
VB 8.0
OS:
Windows Server 2003
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01188523
Message ID:
01188523
Vues:
66
I need some advice.

I am trying to save a parent (doctor) and child (address) object in one hit in such a way that the parent key is auto placed into the child object. I did the following

In the address object i added the foreignkey assignment as follows

Public Sub New()
Me.TableName = "address"
Me.PrimaryKey = ""
Me.DefaultCommandType = CommandType.Text
Me.ForeignParentKeyField = "parent_PK"

then i added a property to doctor called address and registered it as a child object. Then I did the following code in my app test

'' Now we have an address pk we can create DR
Dim loDoctor As Doctor = New Doctor
loDoctor.NewRow()
loDoctor.Entity.First_name = "Erin"
loDoctor.Entity.Last_Name = "Noonan"
loDoctor.Entity.notify_emails = "sales@infotoday.com.au"

'' Create new address first
loDoctor.Address.NewRow()
loDoctor.Address.Entity.post_code = "2060"
loDoctor.Address.Entity.state = "NSW"
loDoctor.Address.Entity.street = "Walker St"
loDoctor.Address.Entity.street_no = "161"
loDoctor.Address.Entity.suburb = "North Sydney"
loDoctor.SaveRow()

this created bith parent and child objects but did not assign the parent key. Am i missing something?
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform