Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Best practice on Foreign Keys
Message
De
19/02/2009 09:34:42
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
 
À
19/02/2009 09:11:19
Information générale
Forum:
ASP.NET
Catégorie:
The Mere Mortals .NET Framework
Versions des environnements
Environment:
ASP.NET
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01382748
Message ID:
01382874
Vues:
36
>Re: Best practice on Foreign Keys Thread #1382748 Message #1382848
>
>I looked through the Jump start as you suggested. I do not see where the Shipper and Employee tables are ever joined. The jump start shows the creation of the classes and the stored procedures, but no relationships.
>
>I like where your going with this, but I still don't know how and where the relationship needs to be done. The record will need to be edited so that when a Crew row is being added the end user has a dropdown box with all of the possible CrewTypes for selection.

The business objects are related when you call the RegisterChildBizObj method of the parent. If you look in the jump start for Web Forms Application C# under step 12 step 4 you will see the following code in the page_load event that registers the OrderDetail as a child of the Order business object.
this.oOrder = (Order) this.RegisterBizObj(new Order()):
this.oOrderDetail = (OrderDetail)this.RegisterBizObj(new OrderDetail());
this.oOrder.RegisterChildBizObj(this.oOrderDetail);
Then for the Employee and Shipper what happens in this case is a bit different and maybe what you are looking for. The shipper and employee are both all retrieved in order to fill the combo boxes. However the proper record is shown in the combo box for the current record because of the way the properties are set up for the combo boxes. All the records are retrieved from the business object so the combo box is filled, but If you look at the same jump start as above but Step 13 the properties being set are allowing the connection to the proper record.

Set the following properties of the combo:
BindingSource in your case would be the CrewType business object as this is the business object you want to pull the CrewType records from for the combo box.
BindingSourceDisplayMember would be your TypeName field that you want to be displayed in the combo box.
BindingSourceValueMember is the CrewType tables PK field which represents the field that will be used to locate the record referenced in your Crew table's FK field.
BindingValueSource is the Crew Business object you are linking to
BindingValueSourceMember is the field that is updated or linked in your Parent (crew) table. This is the Foreign key field.

I hope that helps to sort out what you need to hook it up using a combo box. Basically the plumbing in this case is done in the combo box. If you want to relate the business objects, you can do that by the example above with Order and OrderDetail.
Let me know if you need more info.
Tim
Timothy Bryan
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform