Home Article Practice admin

admin

2022-03-14 15:40  views:427  source:小键人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();



Disclaimer: The above articles are added by users themselves and are only for typing and communication purposes. They do not represent the views of this website, and this website does not assume any legal responsibility. This statement is hereby made! If there is any infringement of your rights, please contact us promptly to delete it.

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