SqlDataAdapter sdaDetail=new SqlDataAdapter();
string str=" select *  from trpTaskDispatch where DispatchID=@DispatchID "+";"+"select * from trpTask";
  SqlCommand cmdD=new SqlCommand(str,conn);
  cmdD.Parameters.Add("@DispatchID",SqlDbType.Int,4);
  cmdD.Parameters["@DispatchID"].Value=68;
  sdaDetail.SelectCommand=cmdD;
  DataSet ds=new DataSet();
  sdaDetail.Fill(ds);
  ds.Tables[0].TableName="order";
  ds.Tables[1].TableName="orders";
  ds.Relations.Add("parentchild",ds.Tables["order"].Columns["DispatchID"],ds.Tables["orders"].Columns["DispatchID"]);
  DataGrid1.DataSource=ds.Tables["order"].DefaultView;
  DataGrid1.DataBind();
 出现错误:不能启用此约束,因为不是所有的值都具有相应的父值。
 语句:ds.Relations.Add("parentchild",ds.Tables["order"].Columns["DispatchID"],ds.Tables["orders"].Columns["DispatchID"]);我的数据库
  trpTaskDispatch              trpTask
DispatchID(主健)                 TaskID(主健)    DispatchID
    68   (一条记录)                1                68
                                     2                68 (多条记录)
小弟菜鸟,不知道那里错拉,求大虾搭救~~万分感谢!