locked
Order bij DESC RRS feed

  • Question

  • Hello ,

    I want to order bij DESC but the outcome in not what i am looking for.

    In Reis i have the numbers of orders , and put it in a datagridview

    For example

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    
    etc

    I want to make this column DESC with this

     cmd = New SqlCeCommand("Select Reis, Datumeindladen From Laden ORDER BY Reis DESC", con)

    But the outcome is this , 20 then 2 that is not what i want.

    Is this possible ?

    20
    2
    19
    18
    17
    16
    15
    14
    13
    12
    11
    10
    1
    

    it has to be

    20
    19
    18
    17
    16
    
    and so on
    When i try to order the datagridview DESC the same outcome 


    Saturday, September 22, 2018 12:21 PM

Answers

  • Looks like your data column is a text data type instead of a numeric data type.  Either change the field type in the database to a numeric type, or do the conversion to a number in your query.

    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    • Marked as answer by KeesBlunder Saturday, September 22, 2018 12:51 PM
    Saturday, September 22, 2018 12:24 PM

All replies

  • Looks like your data column is a text data type instead of a numeric data type.  Either change the field type in the database to a numeric type, or do the conversion to a number in your query.

    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    • Marked as answer by KeesBlunder Saturday, September 22, 2018 12:51 PM
    Saturday, September 22, 2018 12:24 PM
  • If as Reed mentioned you are dealing with a column of type string then you could cast/convert to an integer.

    https://technet.microsoft.com/en-us/library/ms174450(v=sql.110).aspx

    Examples

    SELECT CAST(MyVarcharCol AS INT) FROM Table
    
    SELECT CONVERT(INT, MyVarcharCol) FROM Table


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Saturday, September 22, 2018 12:44 PM
  • Thanks Reed,

    That works , i changed the database .

    Saturday, September 22, 2018 12:51 PM