I have these 2 SQL's. I am populating treeview using these 2 SQL's.
1st SQL is Parent node and 2nd SQL is ChildNode. It is causing performance issue as I looping through Parent Nodes.
is there any way that I can do this using XML. Here both nodes are in same table called Functions
//Parent Node SQL
string MySQL = "SELECT [ID],[Name] FROM .[Functions] WHERE [Parent_Id] IS NULL ORDER BY [NAME] ASC";
//based on Parent nODE, Child Node SQL
string MySQL = "SELECT [ID],[Name] FROM [Functions] WHERE [Parent_ID] ='" + ID + "' ORDER BY [NAME] ASC";
You can,xml,used in this way,is much better——Here's the tiny sample:
【xml】
<?xml version="1.0" standalone="yes"?> <DocumentElement> <book id="bk105"> <author>Corets, Eva</author> <title>The Sundered Grail</title> <genre>Fantasy</genre> <price>5.95</price> <publish_date>2001-09-10</publish_date> <description> The two daughters of Maeve, half-sisters, battle one another for control of England. Sequel to Oberon's Legacy. </description> </book> <book id="bk107"> <author>Thurman, Paula</author> <title>Splish Splash</title> <genre>Romance</genre> <price>4.95</price> <publish_date>2000-11-02</publish_date> <description> A deep sea diver finds true love twenty thousand leagues beneath the sea. </description> </book> <book id="bk108"> <author>Knorr, Stefan</author> <title>Creepy Crawlies</title> <genre>Horror</genre> <price>4.95</price> <publish_date>2000-12-06</publish_date> <description> An anthology of horror stories about roaches, centipedes, scorpions and other insects. </description> </book> <book id="bk109"> <author>Kress, Peter</author> <title>Paradox Lost</title> <genre>Science Fiction</genre> <price>6.95</price> <publish_date>2000-11-02</publish_date> <description> After an inadvertant trip through a Heisenberg Uncertainty Device, James Salway discovers the problems of being quantum. </description> </book> <book id="bk110"> <author>O'Brien, Tim</author> <title>Microsoft .NET: The Programming Bible</title> <genre>Computer</genre> <price>36.95</price> <publish_date>2000-12-09</publish_date> <description> Microsoft's .NET initiative is explored in detail in this deep programmer's reference. </description> </book> <book id="bk111"> <author>O'Brien, Tim</author> <title>MSXML3: A Comprehensive Guide</title> <genre>Computer</genre> <price>36.95</price> <publish_date>2000-12-01</publish_date> <description> The Microsoft MSXML3 parser is covered in detail, with attention to XML DOM interfaces, XSLT processing, SAX and more. </description> </book> <book id="bk112"> <author>Galos, Mike</author> <title>Visual Studio 7: A Comprehensive Guide</title> <genre>Computer</genre> <price>49.95</price> <publish_date>2001-04-16</publish_date> <description> Microsoft Visual Studio 7 is explored in depth, looking at how Visual Basic, Visual C++, C#, and ASP+ are integrated into a comprehensive development environment. </description> </book> </DocumentElement>
【codes】
DataSet ds = new DataSet();
ds.ReadXml("xxx.xml");
TreeView1.Nodes.Add("Books");
foreach(DataRow row in ds.Tables[0].Rows)
{
TreeView1.Nodes[0].ChildrenNodes.Add(row["title"]);
}
ramll
Participant
1127 Points
1299 Posts
Prepare XML file
Jan 10, 2012 09:26 PM|LINK
Hello,
I have these 2 SQL's. I am populating treeview using these 2 SQL's.
1st SQL is Parent node and 2nd SQL is ChildNode. It is causing performance issue as I looping through Parent Nodes.
is there any way that I can do this using XML. Here both nodes are in same table called Functions
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: Prepare XML file
Jan 12, 2012 01:08 AM|LINK
Hello:)
You can,xml,used in this way,is much better——Here's the tiny sample:
【xml】
DataSet ds = new DataSet(); ds.ReadXml("xxx.xml"); TreeView1.Nodes.Add("Books"); foreach(DataRow row in ds.Tables[0].Rows) { TreeView1.Nodes[0].ChildrenNodes.Add(row["title"]); }