?
Solved

Database Sorting Error

Posted on 2008-06-25
1
Medium Priority
?
217 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 2000 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

Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

Question has a verified solution.

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

This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

765 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