Which object is used to add a relationship between two DataTable objects?

 Posted by vishalneeraj-24503 on 12/11/2013 | Category: ADO.NET Interview questions | Views: 2424 | Points: 40

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.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response