Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 20th, 2004, 01:01 AM
Authorized User
 
Join Date: Nov 2003
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Default child table

Hi,

I have two tables in a form, every one in a different dataset.

One table is the master, and the other is the detail.

When I run the form, I select the first row and then I want to add a new record to the child table, but I need to assign a value to the primary key of the child one. I don't know how to do it.

Anybody knows how to establish an automatic relationship to do this or the way to do by hand?

Thanks

-------------------------------
World only exists into your mind.
 
Old August 22nd, 2004, 11:15 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

if they r in diffrent DataSet u ann not do it in design time!
but u could do it in run time as
http://msdn.microsoft.com/library/de...thdatagrid.asp

HTH.

Always:),
Hovik Melkomian.
 
Old August 23rd, 2004, 08:09 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

Use a DataRelationship object, to create a relationship between tables. If you need to reestablish a primary key, do:

objTable.PrimaryKey = New DataColumn() {objTable.Columns("PrimaryKeyField")}

You can use one or more fields that are part of the primary key.

Brian





Similar Threads
Thread Thread Starter Forum Replies Last Post
concurrency violation updating child table karenai VB Databases Basics 1 January 27th, 2008 02:29 AM
Insert Into Parent Child Table prasanta2expert Access VBA 3 November 8th, 2007 11:18 AM
Update parent table with the sum of child table gbrown SQL Language 2 November 9th, 2004 07:53 AM
Parent and Child Records in Same Table owain SQL Language 12 October 27th, 2004 10:02 AM
count child table rows melvik C# 6 January 25th, 2004 01:39 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.