首页 文章 admin

admin

2022-03-14 15:40  浏览数:424  来源:小键人3994802    

//jian li lian jie
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();



声明:以上文章均为用户自行添加,仅供打字交流使用,不代表本站观点,本站不承担任何法律责任,特此声明!如果有侵犯到您的权利,请及时联系我们删除。

字符:    改为:
去打字就可以设置个性皮肤啦!(O ^ ~ ^ O)