Link to home
Start Free TrialLog in
Avatar of computerstreber
computerstreberFlag for United States of America

asked on

Database Sorting Error

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?
ASKER CERTIFIED SOLUTION
Avatar of LordOfPorts
LordOfPorts
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial