Answer: The
DataRelation object is used to add relationship between two
DataTable objects.
Suppose,we have 2 tables employee_master and project_master in which employee_id is common.
So we can add relation as
DataColumn emp_mas_col = DataSet1.Tables["employee_master"].Columns["employee_id"];
DataColumn prj_mas_col = DataSet1.Tables["project_master"].Columns["employee_id"];
//Now Create Their DataRelation as
DataRelation prj_emp = new DataRelation("prj_emp_master", emp_mas_col,prj_mas_col);
//Now Add the relation to the DataSet.
DataSet1.Relations.Add(prj_emp);
Asked In: Many Interviews |
Alert Moderator