Question:

Help in my vb6 SQL order by ?

by  |  earlier

0 LIKES UnLike

when i run the program the combo1 is not on the ASC...

is going like this

1

12

13

2

3

55

6

this is the code i use

Set db = OpenDatabase(App.Path & "/db1.mdb")

Set rs = db.OpenRecordset("select * from school order by studno")

Do Until rs.EOF = True

With Combo1

.AddItem rs!studno

rs.MoveNext

End With

Loop

 Tags:

   Report

2 ANSWERS


  1. I think your SQL datatype is at fault here, perhaps it's text instead of number. Could you change the datatype in your mdb? Otherwise you could aad your items to an array, test the length of the item and pad it with a zero then re-sort the array. This will only work for values less than 100 though.


  2. Try this:

    Set rs = db.OpenRecordset("select * from school order by val(studno)")

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.