C# (.NET 3.5)
I have an SQLite database with two tables - employees (the first column being id INTEGER PRIMARY KEY), and holidays (id INTEGER - meaning the ID of the employee; start DATE, end DATE - self-explanatory).
My form contains textboxes, checkboxes etc. to represent the employee details - but say I'd also like a list box, listing all the holidays for the currently selected employee.
So I need a data relation, as the list box is supposed to display only holidays one person at the time (IDs on both datatables needs to match).
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[0];
DataColumn slave = holidays.Columns[0];
relation = new DataRelation("relation", master, slave);
d.Relations.Add(relation);
var dsView = holidays.DefaultView;
listBox1.DisplayMember = "holidays.relation.start"; // <= it wouldn't look good like that of course, but I just want to get the thing to work for now
listBox1.DataSource = dsView;
- but all I get is a listbox filled up with a bunch of "System.Data.DataRow" In this implementation, I tried to follow the tutorial I found on Akadia... Where do I go wrong? Thanks