-1

I would like to display data in Gridview as below from database for below table. What is the best way to do it? (I am using vfpoledb for Visual FoxPro Database)

EmpTable(From VFP Database)
Name       Date        Time
Mike        4/22/15     11:16
Mike        4/22/15     14:23
Rose       4/22/15     10:45
Rose       4/22/15     11:13        
Jose       4/22/15      14:55
Jose       4/22/15      16:19

In GridView
Name       Date      Time1     Time2
Mike       4/22/15    11:16     14:23
Rose      4/22/15    10:45     11:13
Jose      4/22/15     14:55      16:19

Thanks in advance.

1 Answers1

0

That looks as if you just want to run an SQL Min(), Max() query against your backend, and as if it would not matter whether you mean an ASP.Net GridView or something else.

The VFP prototype syntax could look like

CREATE CURSOR test (Name C(10), Date D, Time C(5))
INSERT INTO test VALUES ("Mike", DATE(2015, 4, 22), "11:16")
INSERT INTO test VALUES ("Mike", DATE(2015, 4, 22), "14:23")
INSERT INTO test VALUES ("Rose", DATE(2015, 4, 22), "10:45")
INSERT INTO test VALUES ("Rose", DATE(2015, 4, 22), "11:13")
INSERT INTO test VALUES ("Jose", DATE(2015, 4, 22), "14:55")
INSERT INTO test VALUES ("Jose", DATE(2015, 4, 22), "16:19")
SELECT name, date, MIN(time), MAX(time) FROM test GROUP BY 1, 2

... where the last line would be the one you'd send via OleDB, and the question could be what you want to happen if there are only one ore more than two results for your given Group By pattern, and why there is no primary key in the table.

Stefan Wuebbe
  • 2,109
  • 5
  • 17
  • 28