DataTable dtData= DbHelperOra.Query(strSql2.ToString()).Tables[0]; //主表
dtusers.TableName = "病人信息";
DataTable dtusers = DbHelperOra.Query(strSql2.ToString()).Tables[0];//从表
dtusers.TableName = "userinfo";
dataSet.Tables.Add(dtusers.Copy()); dataSet.Tables.Add(dtData.Copy()); DataColumn keyColumn = dataSet.Tables["病人信息"].Columns["zhuyh"]; //主表主键 DataColumn foreignKeyColumn = dataSet.Tables["userinfo"].Columns["住院号"];//从表外键 dataSet.Relations.Add("用户产品", keyColumn, foreignKeyColumn); //添加关系 gridControl1.DataSource = dataSet.Tables["病人信息"];//绑定数据 gridControl1.ForceInitialize();