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!
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?
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).
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.
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?
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, 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.
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?