admin
SqlConnection connection = new SqlConnection
("server=.;user=sa;pwd=123;database=session 1");
//da kai lian jie
connection.Open();
SqlDataAdapter adapter = new SqlDataAdapter("
select sport.Name as name from Sport,SportItem
where Sport.SportID=SportItem.SportID group by Sport.name", connection);
DataTable dt = new DataTable();
adapter.Fill(dt);
SqlDataAdapter adapter1 = new SqlDataAdapter
("select Sport.Name as name,SportItem.Name as name1
from Sport,SportItem where Sport.SportID=SportItem.SportID"
, connection);
DataTable dt1 = new DataTable();
adapter1.Fill(dt1);
foreach (DataRow dr in dt.Rows)
{
TreeNode node = new TreeNode(dr["name"].ToString());
foreach
(DataRow dr1 in dt1.Select("name='" + dr["name"].ToString() + "'"))
{
node.Nodes.Add(dr1["name1"].ToString());
}
this.treeView1.Nodes.Add(node);
}
connection.Close();