Delphi Pages Forums

Delphi Pages Forums (http://www.delphipages.com/forum/index.php)
-   General (http://www.delphipages.com/forum/forumdisplay.php?f=2)
-   -   Index by Date Descending (http://www.delphipages.com/forum/showthread.php?t=218659)

kbboykin 02-11-2019 05:18 PM

Index by Date Descending
 
How do I sort my DBGrid by descending date? I want the latest date to be at the top of the grid. I have tried this code to execute on title click. The table is in a master-detail relationship. If I click the column it does as expected, but if I move to another record in master table I get this error: 'Argument are of the wrong type, are out of acceptable range, or in conflict with one another'

Code:

procedure TfrmMain.dbFuelLogTitleClick(Column: TColumn);
begin
  AdatMod.fueling.Sort  := ('fYear DESC');
end;


Marsheng 02-12-2019 03:48 AM

What DB are you running. Often the sorting is a DB function.

kbboykin 02-12-2019 11:25 AM

Quote:

Originally Posted by Marsheng (Post 235204)
What DB are you running. Often the sorting is a DB function.

ADO (ms access 2010). And I have the table sorted in the DB, but still shows up in browse screens in app in ascending order, although I store it in the DB in descending order.

Norrit 02-12-2019 11:38 AM

Try to use a Profiler and see what the generated SQL statement is that goes wrong (usually the last before you get the exception)
This will most likely point in the right direction of what part is false (perhaps you do more and use for example a filter or something at an other point which you don't provide here)

kbboykin 02-13-2019 02:55 PM

Quote:

Originally Posted by Norrit (Post 235206)
Try to use a Profiler and see what the generated SQL statement is that goes wrong (usually the last before you get the exception)
This will most likely point in the right direction of what part is false (perhaps you do more and use for example a filter or something at an other point which you don't provide here)

I'm sorry, I don't understand what a profiler is. I am using ADO directly without SQL -- I use ADOtables with ADOConnection in my app.

Norrit 02-14-2019 10:07 AM

A profiler is an application that lets you see all communication to a database.
Not sure if MsAccess has one (I use it all the time for SQL Server), you should try to google that.

Otherwise you could take a look at the ADOConnection.OnWillExecute event. Log all that goes by there, this should be the point where you can see what the queries that get executed are (but I thought this will only trace select statements)


All times are GMT. The time now is 04:33 PM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.