0
I’m in trouble and I need help.
I want to popular a treeview with data from an SQL database, but I have an error when putting the data through the code it duplicates everything.
My query:
select
MLSGn01.BarGroup as dep,
MLSGn01.MenuDesc as n01,
MLSGn01.Id,
MLSGn02.MenuDesc as n02,
MLSGn02.Id
from dbo.[SAMECA - P_Q_$MenuListSamecaGest] as MLSGn01
left join dbo.[SAMECA - P_Q_$MenuListSamecaGest] as MLSGn02 on MLSGn01.Id = MLSGn02.ParentID
where MLSGn01.ParentID = 0"
Code:
` SqlCommand cmd = new SqlCommand(query, log.connNAV);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
TreeNode node = new TreeNode(dr["dep"].ToString());
node.Nodes.Add(dr["n01"].ToString());
node.Nodes.Add(dr["n02"].ToString());
treeView_menus.Nodes.Add(node);
} `
Error:
Where "Dep" = Groupsales
Where "N01" = Budget
Being "N02" = Budget Maintenance / Prices Cost
Goal:
what data is returned in the query?
– Rovann Linhalis
In any case, my reply yesterday partly settles that. Remember to mark your response if it helped you, and if you have difficulties go to [tour] to see how the community works.
– Rovann Linhalis