Dropdown displaying data in the wrong order

I

Irishmaninusa

Hello Everyone,

I am populating a dropdown control from a database where the data is
datetime values. In my stored procedure I am ordering them by where the most
recent is at the top and the earliest is the last. So the following is
displayed in SQL Query Analyzer

7/28/2004
7/1/2004
6/302004

The above order is correct and that is the way I expect them to be displayed
in the drop down. However in the drop down they get displayed as follow(s):

7/28/2004
6/302004
7/1/2004

I am not exactly sure why it is being displayed like this, because when I
step through the code I can see it been put in the correct order, so I was
wondering if anyone had any ideas on this.

The code that is doing this is as follow(s):


ResetParameters()

..AddParameter("iMRN", OleDb.OleDbType.Integer, ParameterDirection.Input,
ctlHeader.PatientData("PatientMRN"))

'Pull back the list of encounters for the selected patient

If .Execute(.genuSql.StoreProcSelect, "selPatient_Billing") Then

Dim oRow As DataRow

oData = .DbData_DataTable



If .DbData_DataTable.Rows.Count > 0 Then

With drpEnc

..DataSource = oData

..DataBind()

..DataValueField = "id"

..DataTextField = "DateOfService"

End With

End If

Else

Throw New Exception(.ErrorMessage)

End If 'Encounter List


Any help would be appreciated.

JD
 
B

Ben Lucas

Does the Stored Procedure have an "order by" clause in it? If you don't
specify an "order by" clause in SQL Server, then the result set is not
guaranteed to have any specific order.

The other option would be to take your resultset and put it into a DataView
and sort with the DataView.

--
Ben Lucas
Lead Developer
Solien Technology, Inc.
www.solien.com

"Irishmaninusa"
 
I

Irishmaninusa

yes, the stored procedure has a order clause in it (thought I had mentioned
that down below, sorry if I hadn't made it clear enough).

I will take a look at the dataview, but I am not sure if that will work for
this situation.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top