Page 1 of 1

How to disable automatic sorting by primary key in Delphi application that use Microsoft SQL Server database

Posted: Thu 31 May 2018 12:52
by unused_username
I have a Delphi application in which, on edit record data, the record is sorted automatically by primary key. I want that record, after it is edited, remains in the same position. How to do that?

Note that I want this to be done in application, not just in SQL Server database, because then, every time the application is on some computer, there should be changes to SQL SERVER database through management studio.

Re: How to disable automatic sorting by primary key in Delphi application that use Microsoft SQL Server database

Posted: Fri 01 Jun 2018 12:49
by wilton_radinfo
you should be passing some value to the indexfieldnames property,

another detail and that it is not common for an application to allow the user to change values ​​from the primary key of the table, it would be good to prevent this.

Re: How to disable automatic sorting by primary key in Delphi application that use Microsoft SQL Server database

Posted: Tue 05 Jun 2018 08:47
by Stellar
If no index was set for TMSTable/TMSQuery, then after changing, the record in the client DataSet will remain in the same position. If, after changing the record, you will update the Dataset data, for example by calling the Refresh method, then the server can return data where the changed record may take a different position. Unfortunately, we cannot influence the server behavior, you can read more information about this behavior in MS SQL Server documentation.