Solved

Database Sorting Error

Posted on 2008-06-25
1
210 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 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

25 Experts available now in Live!

Get 1:1 Help Now