首頁 文章 admin

admin

2022-03-14 15:40  瀏覽數:414  來源:小键人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)