Results 1 to 4 of 4

Thread: [RESOLVED] Identity Specification Column in Table Not Displaying In Numerical Order

  1. #1

    Thread Starter
    Fanatic Member EntityX's Avatar
    Join Date
    Feb 2007
    Location
    Omnipresence
    Posts
    798

    Resolved [RESOLVED] Identity Specification Column in Table Not Displaying In Numerical Order

    The title of this thread says it all. I have a database table and the column that has identity specification set to true is not displaying in numerical order. Whether I use Server Explorer and use Show Table Data or I create an application to view the contents of the table using a DataGridView I see that column displayed with the numbers often though not always in a non-numerical order.

    Does it perhaps have to do with the way the rows for that column were added or would it be something else. I was looking at the properties for that column but don't see what I would change to make the rows display in numeric order.
    Last edited by EntityX; Oct 4th, 2011 at 12:19 AM.
    Make as many mistakes as you can as quickly as you can. We want to make sure that we make a great enough number of mistakes in a given amount of time so that we can be successful.

    "Persistence is the magic of success." Paramahansa Yogananda

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Identity Specification Column in Database Table Not Displaying In Numerical Order

    The only way to be sure that a database system will return records in a particular order is to explicitly ask for it, using an Order By clause or the equivalent (perhaps via properties of the DataGridView for example), eg:
    Code:
    SELECT fieldA, fieldB
    FROM table1
    ORDER BY fieldA Asc, fieldB Desc
    If you don't specify an order, the database system can return the records in any order it wants at that particular moment, which can vary from one time to the next for a variety of reasons (including pages that are already stored in memory, multiple user locking, relevant indexes available, etc).

  3. #3

    Thread Starter
    Fanatic Member EntityX's Avatar
    Join Date
    Feb 2007
    Location
    Omnipresence
    Posts
    798

    Re: Identity Specification Column in Database Table Not Displaying In Numerical Order

    Ok, thanks for the reponse. When I said, "I see that column displayed with the numbers often though not always in a non-numerical order", that wasn't really what I meant. What I should have said is that parts of the column were in numerical order but other parts weren't.

    Anyway I deleted a bunch of rows from my table so that there were just three left. I then used my code that was adding rows and everything is now displaying in numerical order. I was using different methods at different times to update my table and that might be part of the problem but now I see all the new rows that I added displaying in numerical order so for the time being I won't worry about the problem I saw before. If I see it come back then I'll start to think about it again.
    Make as many mistakes as you can as quickly as you can. We want to make sure that we make a great enough number of mistakes in a given amount of time so that we can be successful.

    "Persistence is the magic of success." Paramahansa Yogananda

  4. #4

    Thread Starter
    Fanatic Member EntityX's Avatar
    Join Date
    Feb 2007
    Location
    Omnipresence
    Posts
    798

    Re: [RESOLVED] Identity Specification Column in Table Not Displaying In Numerical O

    When I marked this resolved I had a feeling I might be seeing this problem again and I did see it again. Taking si's hint I built a query that sorts the column I want in ascending order and now my problem is solved.
    Last edited by EntityX; Oct 4th, 2011 at 12:29 AM.
    Make as many mistakes as you can as quickly as you can. We want to make sure that we make a great enough number of mistakes in a given amount of time so that we can be successful.

    "Persistence is the magic of success." Paramahansa Yogananda

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width