Link to home
Start Free TrialLog in
Avatar of maqskywalker
maqskywalker

asked on

sort by date column descending in vb6 application

I'm using farpoint fpspread grid control inside a old legacy VB6 application.
That is a grid that was used in old VB6 desktop applications

This is the version of VB6 im using:

User generated image
This is the user's guide for the fpspread control:
Spread 8.0 Documentation User’s Guide
http://helpcentral.componentone.com/NetHelp/Spread8/WebSiteHelp/title.html

I have a form with a fpsread control on it , something like this:

User generated image
The data I used to fill the fpspread comes from a table in a sql server database.

The data in the fpspread is not sorted on page load. I want to sort it by one of the date columns.

In the fpspread documention for sorting, it mentions you can either sort using the Spread Designer or set the sorting programmatically with code.
I would like to set the sorting on the fpspread with code.

Sorting Data
http://helpcentral.componentone.com/NetHelp/Spread8/WebSiteHelp/data32.html#659075


If I was using the Employees table from the Northwind database,  and my fpspread was called grdEmployees

How would I set the sort on the fpspread so that on page load it is sorted by HireDate Descending ?

The Employees sql server table looks like this.
I have a stored procedure doing a Select * From Employees to return all the columns from this table.Then in vb6 application I have a function that calls this stored procedure and creates a record set. Then I bind the recordset to the fpspread grid.
I tried setting Order By HireDate Descending in the stored procedure but that did not work. So I think I have to set the sort on th fpspread grid.
User generated image
So I would like to set the sort on the HireDate column so that on page load it displays like this mockup:

User generated image
Script to create the table:

USE [Northwind]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Employees](
	[EmployeeID] [int] IDENTITY(1,1) NOT NULL,
	[LastName] [nvarchar](20) NOT NULL,
	[FirstName] [nvarchar](10) NOT NULL,
	[Title] [nvarchar](30) NULL,
	[TitleOfCourtesy] [nvarchar](25) NULL,
	[BirthDate] [datetime] NULL,
	[HireDate] [datetime] NULL,
	[Address] [nvarchar](60) NULL,
	[City] [nvarchar](15) NULL,
 CONSTRAINT [PK_Employees] PRIMARY KEY CLUSTERED 
(
	[EmployeeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET IDENTITY_INSERT [dbo].[Employees] ON 

INSERT [dbo].[Employees] ([EmployeeID], [LastName], [FirstName], [Title], [TitleOfCourtesy], [BirthDate], [HireDate], [Address], [City]) VALUES (1, N'Davolio', N'Nancy', N'Sales Representative', N'Ms.', CAST(N'1948-12-08T00:00:00.000' AS DateTime), CAST(N'2018-05-19T00:00:00.000' AS DateTime), N'507 - 20th Ave. E.
Apt. 2A', N'Seattle')
INSERT [dbo].[Employees] ([EmployeeID], [LastName], [FirstName], [Title], [TitleOfCourtesy], [BirthDate], [HireDate], [Address], [City]) VALUES (2, N'Fuller', N'Andrew', N'Vice President, Sales', N'Dr.', CAST(N'1952-02-19T00:00:00.000' AS DateTime), CAST(N'2018-05-18T00:00:00.000' AS DateTime), N'908 W. Capital Way', N'Tacoma')
INSERT [dbo].[Employees] ([EmployeeID], [LastName], [FirstName], [Title], [TitleOfCourtesy], [BirthDate], [HireDate], [Address], [City]) VALUES (3, N'Leverling', N'Janet', N'Sales Representative', N'Ms.', CAST(N'1963-08-30T00:00:00.000' AS DateTime), CAST(N'2012-08-15T00:00:00.000' AS DateTime), N'722 Moss Bay Blvd.', N'Kirkland')
INSERT [dbo].[Employees] ([EmployeeID], [LastName], [FirstName], [Title], [TitleOfCourtesy], [BirthDate], [HireDate], [Address], [City]) VALUES (4, N'Peacock', N'Margaret', N'Sales Representative', N'Mrs.', CAST(N'1937-09-19T00:00:00.000' AS DateTime), CAST(N'2013-04-13T00:00:00.000' AS DateTime), N'4110 Old Redmond Rd.', N'Redmond')
INSERT [dbo].[Employees] ([EmployeeID], [LastName], [FirstName], [Title], [TitleOfCourtesy], [BirthDate], [HireDate], [Address], [City]) VALUES (5, N'Buchanan', N'Steven', N'Sales Manager', N'Mr.', CAST(N'1955-03-04T00:00:00.000' AS DateTime), CAST(N'2018-03-17T00:00:00.000' AS DateTime), N'14 Garrett Hill', N'London')
INSERT [dbo].[Employees] ([EmployeeID], [LastName], [FirstName], [Title], [TitleOfCourtesy], [BirthDate], [HireDate], [Address], [City]) VALUES (6, N'Suyama', N'Michael', N'Sales Representative', N'Mr.', CAST(N'1963-07-02T00:00:00.000' AS DateTime), CAST(N'2017-10-17T00:00:00.000' AS DateTime), N'Coventry House
Miner Rd.', N'London')
INSERT [dbo].[Employees] ([EmployeeID], [LastName], [FirstName], [Title], [TitleOfCourtesy], [BirthDate], [HireDate], [Address], [City]) VALUES (7, N'King', N'Robert', N'Sales Representative', N'Mr.', CAST(N'1960-05-29T00:00:00.000' AS DateTime), CAST(N'2018-01-02T00:00:00.000' AS DateTime), N'Edgeham Hollow
Winchester Way', N'London')
INSERT [dbo].[Employees] ([EmployeeID], [LastName], [FirstName], [Title], [TitleOfCourtesy], [BirthDate], [HireDate], [Address], [City]) VALUES (8, N'Callahan', N'Laura', N'Inside Sales Coordinator', N'Ms.', CAST(N'1958-01-09T00:00:00.000' AS DateTime), CAST(N'1994-03-05T00:00:00.000' AS DateTime), N'4726 - 11th Ave. N.E.', N'Seattle')
INSERT [dbo].[Employees] ([EmployeeID], [LastName], [FirstName], [Title], [TitleOfCourtesy], [BirthDate], [HireDate], [Address], [City]) VALUES (9, N'Dodsworth', N'Anne', N'Sales Representative', N'Ms.', CAST(N'1966-01-27T00:00:00.000' AS DateTime), CAST(N'1994-11-15T00:00:00.000' AS DateTime), N'7 Houndstooth Rd.', N'London')
SET IDENTITY_INSERT [dbo].[Employees] OFF

Open in new window

NWEmployeesTableDesired.png
ASKER CERTIFIED SOLUTION
Avatar of Nakul Vachhrajani
Nakul Vachhrajani
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial