Solved

Database Sorting Error

Posted on 2008-06-25
1
211 Views
Last Modified: 2010-04-15
I have developed the following code to fill a TreeView control:

private void FillServerList()
            {
                  //MySelectCommand.CommandText =  "nsp_get_server_name";
            MySelectCommand.CommandText = "uspGetStatus";
                  dreader = MySelectCommand.ExecuteReader();
                  tvwServDB.Nodes.Clear();
                  while (dreader.Read())
                  {
                        //WorkNode = tvwServDB.Nodes.Add(dreader["server_name"].ToString());
                WorkNode = tvwServDB.Nodes.Add(dreader["Status_Desc"].ToString());
                        //WorkNode.ForeColor = SetStatusColor(dreader["status_desc"].ToString());
                  }
                  dreader.Close();
                  
            }

The code itself works perfectly. However, the result set is ordered differently than the SQL statement output. For example, the stored procedure that is executed above results in the following:

P
O
D
C

This is how I want to have it show up. Unfortunately, my treeview shows the same data like this:

C
D
O
P

How can I keep Visual Studio from sorting this?
0
Comment
Question by:computerstreber
1 Comment
 
LVL 19

Accepted Solution

by:
LordOfPorts earned 500 total points
ID: 21870420
The TreeView object has a boolean property named Sorted http://msdn.microsoft.com/en-us/library/system.windows.forms.treeview.sorted.aspx that you can set to false, e.g.:

tvwServDB.Sorted = false;
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now