**EDIT
Attaching a screenshot for a basic outline of how I need it to display. Names on top, times on the side next to the corresponding stamp. It's a vague imitation of a calendar...sorta.
**END EDIT
This is going to be a pretty elaborate query when it's done and I'm just looking for second opinions on the approach/execution.
I've got a database setup with two tables currently relevant, Users and Tasks. What I need to do is go through the users table, get all the names that have the usertype "employee" (another column in that table obviously), and then pull anything assigned to them from the Tasks table, and group them by the times assigned (but i need the names as column headers. I tried a basic query,
SELECT username FROM Users WHERE type = 'employee'
and then iterating through the table that filled to query each employee one at a time and adding them to a second table. Needless to say, this was an epic fail.
foreach(DataRow row in newTable.rows) { OleDbDataAdapter da = new OleDbDataAdapter("SELECT Employee As [" + s1 + "], ScheduledStartDate, ScheduledEndDate FROM Tasks WHERE Employee = " + s1 + "GroupBy(ScheduledStartDate), this.oCon); table2.Rows.Add(row); }
All I'm getting is errors about the rows belonging to tables and a few randoms about "reserved keywords", but regardless, so far it's not working. Syntax errors aside, I don't think this is the best or even workable approach. Thanks in advance to whoever wants to share a better one! And apologies to whatever moderator decides this is in the wrong category and moves it, happens every time these last few years.
May the fleas of a thousand camels feast happily on the lower regions of your enemies. And may their arms be too short to scratch!