Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First of all, you have named variables employees and holidays, but that does mean the tables within the dataset have names changed; they are still set to the default names, which, in your case are table and table1. (They would normally be table, table1 ... tableN) That means that your display member property should be as follows:</p> <pre><code>listBox1.DisplayMember = "table.relation.start"; </code></pre> <p>Also, make sure you databind to the dataset itself rather than the holiday table within the dataset as follows:</p> <pre><code>listBox1.DataSource = d; </code></pre> <p>With these two changes, you should find that it works; this.BindingContext should help in navigating the parent records as you will notice only 1 set of child (holiday) results are shown at at time.</p> <p>Complete modified code as follows:</p> <pre><code> var command = new SQLiteCommand("SELECT * FROM employees; SELECT * FROM holidays"); var connection=new SQLiteConnection(@"data source=C:\employees.db"); command.Connection = connection; SQLiteDataAdapter adapter = new SQLiteDataAdapter(command); DataSet d = new DataSet(); adapter.Fill(d); DataTable employees = d.Tables[0]; // [...] // here I'm databinding my textboxes etc. to various columns // of the employees data table - this works fine, navigation works well etc. // [...] DataTable holidays = d.Tables[1]; DataRelation relation; DataColumn master = employees.Columns["id"]; DataColumn slave = holidays.Columns["employeeid"]; relation = new DataRelation("relation", master, slave); d.Relations.Add(relation); listBox1.DisplayMember = "table.relation.start"; // &lt;= it wouldn't look good like that of course, but I just want to get the thing to work for now listBox1.DataSource = d; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload