Solved

Database Sorting Error

Posted on 2008-06-25
1
216 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

691 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