title: This constraint cannot be enabled as not all values have corresponding parent values
body: <p>I have three nested tables in a dataset. I display the data based on the language ID, ie: EN is 1 FR is 2 and NL is 3. French and english exist in the database but Dutch does not exist yet and when the user selects NL I get the following error:</p>
  
  <blockquote>
    <p>This constraint cannot be enabled as not all values have corresponding
    parent values.</p>
  </blockquote>
  
  <p>Below is the code that I use to get the data. The error happens when I try to create relations in the dataset.</p>
  
  <pre><code> (ds.Relations.Add(new DataRelation("Cat_SubCat", dk1, dk2));
  </code></pre>
  
  <p>Now my question is, how can I check if the value exists in the dataset or database with the given code below?</p>
  
  <pre><code> public static DataTable GetData(Int32 languageID)
      {
          DataSet ds = new DataSet();
  
          string commandText = @"SELECT * FROM AlacarteCat where languageID = @ID;
                                 SELECT * FROM AlacarteSubCat where languageID = @ID;
                                 SELECT * from AlacarteItems where languageID = @ID";
  
          using (SqlConnection myConnection = new SqlConnection(Common.GetConnectionString("SQLConnectionString")))
          {
             SqlCommand command = new SqlCommand(commandText, myConnection);
              command.Parameters.Add("@ID", SqlDbType.Int);
              command.Parameters["@ID"].Value = languageID;
  
              SqlDataAdapter da = new SqlDataAdapter();
              da.SelectCommand = command;
              da.TableMappings.Add("AlacarteCat", "AlacarteCat"); // table 0
              da.TableMappings.Add("AlacarteSubCat", "AlacarteSubCat"); // table 1
              da.TableMappings.Add("AlacarteItems", "AlacarteItems"); // table 2
              da.Fill(ds, "AlacarteCat");
  
              DataColumn dk1 = ds.Tables[0].Columns["ID"];
              DataColumn dk2 = ds.Tables[1].Columns["AlacarteCatID"];
              DataColumn dk3 = ds.Tables[1].Columns["ID"];
              DataColumn dk4 = ds.Tables[2].Columns["AlacarteSubCatID"];
              DataColumn dk5 = ds.Tables[0].Columns["id"];
              DataColumn dk6 = ds.Tables[2].Columns["AlacarteCatID"];
              ds.Relations.Add(new DataRelation("Cat_SubCat", dk1, dk2));
              ds.Relations.Add(new DataRelation("SubCat_Items", dk3, dk4));
              ds.Relations.Add(new DataRelation("Cat_Items", dk5, dk6));
  
              if ((ds != null))
              {
                  return ds.Tables["AlacarteCat"];
              }
              return null;
          }
  
      }
  </code></pre>