I am using SQL server compact edition as the backend in my winform application.
I have a column timestamp in one of my tables. I have stored timestamp as follows :
DateTime dt = System.DateTime.Now;
long timestamp = dt.Ticks;
It stores a long value representing current date and time into the database.
I want to display table’s data in a DataGridView control by setting its DataSource property.
When I retrieve table data using SQL query “select * from my-table” and attach to DataSource, it just displays timestamp as a long value.
My question is :
How can I convert timestamp back to DateTime value in dd-mm-yyyy format before displaying it in the DataGridView?
If you using datatable, you can do this:
Check this to convert sqlceresultset.resultview to datatable: Convert SQLCEResultSet resultview to datatable