Sexy Sahil said bad, bad things about ADO.NET 2.0's Strongly Typed DataSets. He's an MVP and he made good points. Me? I'm just a simple developer who is always grateful when I don't have to think much. And one of those nasty ADO.NET 1.0 features requiring me to think more than I had to was having to write
dt.Rows[0]["SomeHardToRememberFieldName"]
Not only did I have to type out the whole darn field name, I had to pop open the Server Window to display the table/view fields. Now, thanks to the new DataTableAdapter and other ADO.NET 2.0 Strongly Typed sweetness, I don't have to. Check out these two examples of populating a TreeView Control in ADO.NET 1.0 and 2.0. First the ADO.NET 1.0 way:
foreach (DataRow row in m_subject.Staffers.Rows)
{
TreeNode stafferNode = new TreeNode((string)row["DisplayName"]);
stafferNode.Tag = (int)row["StafferID"];
int icon = (int)GetIconType((string)row["StafferType"]);
stafferNode.ImageIndex = icon;
stafferNode.SelectedImageIndex = icon;
staffersNode.Nodes.Add(stafferNode);
}
Now for the ADO.NET 2.0 version:
foreach (MyDataSet.dtUsersRow rw in myDataSet.dtUsers.Rows)
{
TreeNode stafferNode = new TreeNode(rw.DisplayName);
stafferNode.Tag = rw.StafferID;
int icon = (int)GetIconType(rw.StafferType);
stafferNode.ImageIndex = icon;
stafferNode.SelectedImageIndex = icon;
staffersNode.Nodes.Add(stafferNode);
}
THAT oughta help you Put On a Happy Face! (If it doesn't and you're still blue, think of Janet Leigh as she looked in Bye-Bye Birdie.)