|
-
Sep 10th, 2005, 10:03 AM
#1
Thread Starter
Frenzied Member
data relationships
Hello
I am creating some relationships in code. I have 3 tables Position, Department, and Employee. The relationship is a one to many for these tables. See the details below.
PositionNames are manager, secretary etc
Position - PositionID (PK), PositionName
Department - DepartmentCode (PK), NameOfDepartment
Employee - EmployeeNo (PK), Name, Address, PositionID(FK), DepartmentCode(FK)
I have created a relation with the department and employee as follows:
Code:
DataColumn parentColumn = ds.Tables["Department"].Columns["DepartmentCode"];
DataColumn childColumn = ds.Tables["Employee"].Columns["DepartmentCode"];
ds.Relations.Clear();
dRelEmployees = new DataRelation("EmployeeDetails",parentColumn,childColumn);
ds.Relations.Add(dRelEmployees);
My problem is l want to add another parent column for the position, do l need to repeat all this code just for the position table. Or can l add another parentColumn and add them all to the dRelEmployees DataSet.
Not sure how to do this.
Thanks in advance,
Steve
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|