I am trying to add child nodes based on database query in which the users in the database are a part of the parent node. Here is my code.
[CODE=c#]private void GetUsersByGroup ()
{
//Setup query
MySqlCommand cmdDatabase = new MySqlCommand("S ELECT group_name FROM prov_groups WHERE group_name!='--None--';", conDatabase);
cmdDatabase.Exe cuteNonQuery();
MySqlDataReader myReader;
// Get data from query and send to tree view
myReader = cmdDatabase.Exe cuteReader();
while (myReader.Read( ))
{
treeUsers.Nodes .Add(myReader.G etString(0));
}
myReader.Close( );
int groupNodeCount = treeUsers.GetNo deCount();
for (int i = 0; i <= groupNodeCount; i++)
{
cmdDatabase = "SELECT Name FROM tsms LEFT JOIN prov_groups ON (tsms.Group = prov_groups.gid AND prov_groups.nam e='"+treeUsers. Nodes[i].Text.ToString( )+"');";
cmdDatabase.Exe cuteNonQuery();
myReader = cmdDatabase.Exe cuteReader();
while (myReader.Read( ))
{
// ADD CHILD NODES HERE
}
myReader.Close( );
}[/CODE]
I'm having trouble adding the child nodes to the parent nodes that are already in the treeview. Can someone lend a helping hand on this?
Thanks in advance.
[CODE=c#]private void GetUsersByGroup ()
{
//Setup query
MySqlCommand cmdDatabase = new MySqlCommand("S ELECT group_name FROM prov_groups WHERE group_name!='--None--';", conDatabase);
cmdDatabase.Exe cuteNonQuery();
MySqlDataReader myReader;
// Get data from query and send to tree view
myReader = cmdDatabase.Exe cuteReader();
while (myReader.Read( ))
{
treeUsers.Nodes .Add(myReader.G etString(0));
}
myReader.Close( );
int groupNodeCount = treeUsers.GetNo deCount();
for (int i = 0; i <= groupNodeCount; i++)
{
cmdDatabase = "SELECT Name FROM tsms LEFT JOIN prov_groups ON (tsms.Group = prov_groups.gid AND prov_groups.nam e='"+treeUsers. Nodes[i].Text.ToString( )+"');";
cmdDatabase.Exe cuteNonQuery();
myReader = cmdDatabase.Exe cuteReader();
while (myReader.Read( ))
{
// ADD CHILD NODES HERE
}
myReader.Close( );
}[/CODE]
I'm having trouble adding the child nodes to the parent nodes that are already in the treeview. Can someone lend a helping hand on this?
Thanks in advance.
Comment