473,811 Members | 2,685 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to generate TreeView using DataReader?

126 New Member
Hullo Awesome Friends,

WINDOW Based Application using VBNET2008, DataReader and TreeView Control Nodes
I need your help, Please help me.

I am using TreeView controls and having problem writing the coding as I have not done it before.

Listed beow are the SQL String and the result of it. And also the Proposed Desired display on TreeView.

SQL String :
SELECT OrderID, OrderDate ProductID
FROM Invoices WHERE (CustomerID = N'Chops') Order by OrderID, Orderdate

Result of SQL String
OrderId OrderDate ProdID
10254 11/07/1996 74
10254 11/07/1996 24
10254 11/07/1996 55
10254 23/07/1996 105
10254 23/07/1996 96
10254 25/07/1996 82

10370 03/12/1996 74
10370 03/12/1996 1
10370 03/12/1996 64
10370 03/12/1996 56

10519 28/04/1997 10
10519 28/04/1997 60

---------------------------------------------------------
Proposal Desired TreeView Display Format during RunTime
How to use DataReader (While DR.READ()) in order to create the structure listed below
10254
|______11/07/1996
|__________74
|__________24
|_________ 55
|______ 23/07/1996
|_________ 105
|_________ 96
|_________ 82


10370
|______03/12/1996
|_________74
|_________1
|_________64
|_________56

10519
|_______28/04/1997
|________

Thank you very much for your help.
Feb 8 '11 #1
1 2492
pod
298 Contributor
what you might want to do is add the parent nodes (Order ID) in the _Load method and add the child nodes in _BeforeExpand method
Expand|Select|Wrap|Line Numbers
  1. (_Load method)
  2. nodecnt = 0
  3. While reading [distinct_Order_ID result set]
  4.    myTreeView.Nodes.Add(Order ID)
  5.    myTreeView.Nodes(nodecnt).Nodes.Add("Empty")
  6.    nodecnt += 1
  7. Loop
  8.  
  9. (BeforeExpand method)
  10. If e.Node.Level = 0 Then
  11.    e.Node.Nodes.Clear()
  12.    nodecnt = 0
  13.    <-- create query based on the selected Order ID "e.Node.Name"-->
  14.    While reading [invoices_selected_Order_ID result set]
  15.       <-- firstencounter-->
  16.       'here you have to put in some conditional stuff to add only and Order Date node when first encountered
  17.       if firstencounter then
  18.           Me.edaTreeView.Nodes(e.Node.Name).Nodes.Add(Order Date)
  19.       end if
  20.       <-- end of firstencounter-->
  21.       Me.edaTreeView.Nodes(e.Node.Name).Nodes(nodecnt).Add(ProductID)
  22.       <-- firstencounter-->
  23.       if firstencounter then
  24.          nodecnt += 1
  25.       end if
  26.       <-- end of firstencounter-->
  27.    Loop
  28.  
  29. End If
  30. Loop
  31.  
Feb 8 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1539
by: Ravi | last post by:
i tried with MS treeview control but i am unable to implement all the requirements.This requiement like when user login will generate the menu and display it. After that we need to Add or remove the nodes from the tree from client side. 1.Selected node should be highlighted and non active. 2.some group of pages related to same category EX : registration process Aggrement,userinformation,login information and
1
3102
by: Aleksey | last post by:
Hi, All! I have a problem with TreeView component. My TreeView consists of two nodes Node1 and Node2. On click of right mouse button TreeView has event. In this event I check wich node is selected. At the start Node1 is selected. But when I do right click on Node2 the selected node remain Node1. It changed only after left click. Q: How can I check on wich node was right click? Or how can I make TreeView to change selected node by node...
0
1184
by: pedaammulu | last post by:
Hi, I have put up a page which can help you to understand the workings of how to access SQL data using VB.Net. http://www.vkinfotek.com/datareader.html All info on the page and site is to help programmers understand application development techniques. Regards
1
2276
by: nasirmajor | last post by:
Dear All, im fetching record from database using datareader, and is displaying them in the textboxes. when user change the text fields and then presses the update button the record should be updated but what happen is: form is postedback but no change happen to database and also textboxes return to there original state i.e previous record(enableviewstate is false/same result with true). small code is here:...
1
21629
by: watsod1 | last post by:
Hello, This is my first post, Hello to all. This also a test post to make sure that I am doing the right thing and following rules etc. I have been searching for a way to make the treeview display multiple lines of text on each treeview node (treenode). After searching for answers and not finding any, I stumbled on the solution in the msdn help files (search for TreeView.DrawNode Event). It has source code that shows how to display...
2
1434
by: bindu123 | last post by:
Hi All, I have to generate a line chart in C on windows, using distance in the X-axis and throughput in Y-axis. Is it possible to generate charts using C programming in windows ? and i also i would like to develop a GUI interface, please guide me what should be used for the same ? Thanks for your help...
4
1472
by: sreedevipd | last post by:
Hi all, I need to create a treeview using javascript and xml ...i am stuck with the same issue ..can anybody help... I am using C#Asp.net Thanks in Advance sridevi
0
1400
by: Selun | last post by:
Hi all, First of all im not sure if this is the correct section to ask this. Im using C# .NET I m trying to populate a gridview using datareader with the following code protected void page_load (object sender, System.EventArgs e) {
0
1292
by: Teka Cherenet | last post by:
I am newer for programming world in C# and SQL Server. so I wonder if it is possible to have a sample code which illustrates how to generate report using C# code. thank you
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10647
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9204
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6889
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5554
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4339
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3865
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3017
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.