s19k15 s19k15 - 1 year ago 78
C# Question

Database Records Order

i am developing an application for windows phone in c# using sql compaq for database in order to make it simple as plug and play.

The problem is that if i delete a record in my database and make an new insert the record is displayed at the position of deleted record and not at the bottom as last insert.

Note that i dont have any primary key such as id or any date column to sort and get the rows in fifo.
The important thing is to not add any other column in this database to make the sort, i am trying to find a way to change the behavior.

I searched a lot to make a sort with the order of the insertments but i didn't found anything as database does not relocate the rows after a deletion because uses the empty space of deleted record in order to use less the disk.

So how can i make the records display in the same way they were inserted?

Answer Source

There is no guaranteed database "order". You need to specify a sort field with Order By.

If this is really a requirement, then as you suggest a monotonically increasing primary key integer or createdOn column is required

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download