Welcome to Dream.In.Code
Getting VB.NET Help is Easy!

Join 136,475 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,590 people online right now. Registration is fast and FREE... Join Now!




Treeview -> MySQL

 
Reply to this topicStart new topic

Treeview -> MySQL

pe_mitev
3 Jul, 2008 - 10:59 AM
Post #1

D.I.C Head
Group Icon

Joined: 28 Dec, 2007
Posts: 71


Dream Kudos: 50
My Contributions
Hello! I need to save each node from a treeview into a MYSQL database or let's say I need a general idea of how to organize the SQL tables. I was thinking of recording each item and record also its parent, but I could not realize it this way. How would you solve such a problem?
User is offlineProfile CardPM
+Quote Post

modi123_1
RE: Treeview -> MySQL
3 Jul, 2008 - 11:10 AM
Post #2

D.I.C Addict
Group Icon

Joined: 12 Jun, 2008
Posts: 531



Thanked: 13 times
Dream Kudos: 100
My Contributions
QUOTE(pe_mitev @ 3 Jul, 2008 - 01:59 PM) *

Hello! I need to save each node from a treeview into a MYSQL database or let's say I need a general idea of how to organize the SQL tables. I was thinking of recording each item and record also its parent, but I could not realize it this way. How would you solve such a problem?


Your SQL table would look like this:
lID (unique id key for the nodes)
sDescription
lParentID (the parent id's unique number).

Peel them off and fill in the blanks.
User is offlineProfile CardPM
+Quote Post

pe_mitev
RE: Treeview -> MySQL
3 Jul, 2008 - 12:13 PM
Post #3

D.I.C Head
Group Icon

Joined: 28 Dec, 2007
Posts: 71


Dream Kudos: 50
My Contributions
Yes, it exactly looks this way. Actually, I have the following problem that prevent the coming of the success.

1) I do not know if I can set unique ID for each node.

Anyonre, that ever have had a simillar problem and now remember thw way he had solved it?
User is offlineProfile CardPM
+Quote Post

modi123_1
RE: Treeview -> MySQL
3 Jul, 2008 - 12:57 PM
Post #4

D.I.C Addict
Group Icon

Joined: 12 Jun, 2008
Posts: 531



Thanked: 13 times
Dream Kudos: 100
My Contributions
QUOTE(pe_mitev @ 3 Jul, 2008 - 03:13 PM) *

Yes, it exactly looks this way. Actually, I have the following problem that prevent the coming of the success.

1) I do not know if I can set unique ID for each node.

Anyonre, that ever have had a simillar problem and now remember thw way he had solved it?


Well the "key" is your unique id.. but the unique id was meant for the DB.. what you should do is create your own class. have it extend the library's node class and add a new variable called "unique id". Check out inheritance if you dont know how.

BTW, I've done this before..
User is offlineProfile CardPM
+Quote Post

pe_mitev
RE: Treeview -> MySQL
3 Jul, 2008 - 11:29 PM
Post #5

D.I.C Head
Group Icon

Joined: 28 Dec, 2007
Posts: 71


Dream Kudos: 50
My Contributions
QUOTE(modi123_1 @ 3 Jul, 2008 - 01:57 PM) *

QUOTE(pe_mitev @ 3 Jul, 2008 - 03:13 PM) *

Yes, it exactly looks this way. Actually, I have the following problem that prevent the coming of the success.

1) I do not know if I can set unique ID for each node.

Anyonre, that ever have had a simillar problem and now remember thw way he had solved it?


Well the "key" is your unique id.. but the unique id was meant for the DB.. what you should do is create your own class. have it extend the library's node class and add a new variable called "unique id". Check out inheritance if you dont know how.

BTW, I've done this before..


Yes, but after I do this, will be there a method, based on which I will be able to find/select the node I want?
User is offlineProfile CardPM
+Quote Post

modi123_1
RE: Treeview -> MySQL
4 Jul, 2008 - 09:38 AM
Post #6

D.I.C Addict
Group Icon

Joined: 12 Jun, 2008
Posts: 531



Thanked: 13 times
Dream Kudos: 100
My Contributions
QUOTE(pe_mitev @ 4 Jul, 2008 - 02:29 AM) *

QUOTE(modi123_1 @ 3 Jul, 2008 - 01:57 PM) *

QUOTE(pe_mitev @ 3 Jul, 2008 - 03:13 PM) *

Yes, it exactly looks this way. Actually, I have the following problem that prevent the coming of the success.

1) I do not know if I can set unique ID for each node.

Anyonre, that ever have had a simillar problem and now remember thw way he had solved it?


Well the "key" is your unique id.. but the unique id was meant for the DB.. what you should do is create your own class. have it extend the library's node class and add a new variable called "unique id". Check out inheritance if you dont know how.

BTW, I've done this before..


Yes, but after I do this, will be there a method, based on which I will be able to find/select the node I want?


Are you talking about in the DB or in the VB code? If it's in the VB code.. well how do you want it to select it? What I did was rolled my own 'search method' that takes in the unique lID and just runs through the tree.. fairly simple..
User is offlineProfile CardPM
+Quote Post

pe_mitev
RE: Treeview -> MySQL
4 Jul, 2008 - 11:36 PM
Post #7

D.I.C Head
Group Icon

Joined: 28 Dec, 2007
Posts: 71


Dream Kudos: 50
My Contributions
QUOTE(modi123_1 @ 4 Jul, 2008 - 10:38 AM) *

QUOTE(pe_mitev @ 4 Jul, 2008 - 02:29 AM) *

QUOTE(modi123_1 @ 3 Jul, 2008 - 01:57 PM) *

QUOTE(pe_mitev @ 3 Jul, 2008 - 03:13 PM) *

Yes, it exactly looks this way. Actually, I have the following problem that prevent the coming of the success.

1) I do not know if I can set unique ID for each node.

Anyonre, that ever have had a simillar problem and now remember thw way he had solved it?


Well the "key" is your unique id.. but the unique id was meant for the DB.. what you should do is create your own class. have it extend the library's node class and add a new variable called "unique id". Check out inheritance if you dont know how.

BTW, I've done this before..


Yes, but after I do this, will be there a method, based on which I will be able to find/select the node I want?


Are you talking about in the DB or in the VB code? If it's in the VB code.. well how do you want it to select it? What I did was rolled my own 'search method' that takes in the unique lID and just runs through the tree.. fairly simple..


Yes, but thus I think there is a problem with the performance, I am wrong? I will tell you what I have problems with:
1) I found that there is a attribute "Tag", which can be used for user-defined info or let's say the unique ID.
2) I am doing the query this way:
CODE
select unique_id, title, parent_id FROM table ORDER BY parent_id


Thus I was hoping that I will extract the parent and all after it, but it did not become this way. The second way I thought was to integrate a method, which will find a specified node by given unique_id, without caring how deep it is located in the tree. If I am able to build such a method, while I am looping the data from MYSQL, I can simply see the parent_id and call this search function and when it find this parent node, just to add to its nodes the child.

Btw, I organized the table -> unique_id | title(description) | parent_id.

If you can confirm that this is the right way or it is a kind of solution at all, I will try to write such a method, but then I will ask, how to select a node, because I did not find a way this to be done programmly.




User is offlineProfile CardPM
+Quote Post

modi123_1
RE: Treeview -> MySQL
5 Jul, 2008 - 02:10 PM
Post #8

D.I.C Addict
Group Icon

Joined: 12 Jun, 2008
Posts: 531



Thanked: 13 times
Dream Kudos: 100
My Contributions
QUOTE(pe_mitev @ 5 Jul, 2008 - 02:36 AM) *

QUOTE(modi123_1 @ 4 Jul, 2008 - 10:38 AM) *

QUOTE(pe_mitev @ 4 Jul, 2008 - 02:29 AM) *

QUOTE(modi123_1 @ 3 Jul, 2008 - 01:57 PM) *

QUOTE(pe_mitev @ 3 Jul, 2008 - 03:13 PM) *

Yes, it exactly looks this way. Actually, I have the following problem that prevent the coming of the success.

1) I do not know if I can set unique ID for each node.

Anyonre, that ever have had a simillar problem and now remember thw way he had solved it?


Well the "key" is your unique id.. but the unique id was meant for the DB.. what you should do is create your own class. have it extend the library's node class and add a new variable called "unique id". Check out inheritance if you dont know how.

BTW, I've done this before..


Yes, but after I do this, will be there a method, based on which I will be able to find/select the node I want?


Are you talking about in the DB or in the VB code? If it's in the VB code.. well how do you want it to select it? What I did was rolled my own 'search method' that takes in the unique lID and just runs through the tree.. fairly simple..


Yes, but thus I think there is a problem with the performance, I am wrong? I will tell you what I have problems with:
1) I found that there is a attribute "Tag", which can be used for user-defined info or let's say the unique ID.
2) I am doing the query this way:
CODE
select unique_id, title, parent_id FROM table ORDER BY parent_id


Thus I was hoping that I will extract the parent and all after it, but it did not become this way. The second way I thought was to integrate a method, which will find a specified node by given unique_id, without caring how deep it is located in the tree. If I am able to build such a method, while I am looping the data from MYSQL, I can simply see the parent_id and call this search function and when it find this parent node, just to add to its nodes the child.

Btw, I organized the table -> unique_id | title(description) | parent_id.

If you can confirm that this is the right way or it is a kind of solution at all, I will try to write such a method, but then I will ask, how to select a node, because I did not find a way this to be done programmly.


I am not sure what you mean 'performance loss'? On the VB side? To fill a treeview from a dataset should be fairly straight forward for loop. A single node lookup from a dataset is a zero time issue as well.

I am not a hundred percent on board with what you are saying for a solution. Could you elaborate a bit more?
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 06:09PM

Live VB.NET Help!

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month