Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » ArrayCtrl, HeaderCtrl & GridCtrl » Date pasted in GridCtrl saved in sqlite. Problem and solution
Date pasted in GridCtrl saved in sqlite. Problem and solution [message #17704] Tue, 26 August 2008 22:05 Go to previous message
koldo is currently offline  koldo
Messages: 3361
Registered: August 2008
Senior Veteran
Hello all

I have found another problem and I propose you a solution.
The source of this is because when pasting in GridCtrl:
- From the GridCTrl, as it knows the type of the cells, the type of the Value of the cells is right
- From outside, as it does not know the type, all data are Values of type String

Using the standard SetDateScan there is no problem, but when changing it (for examle SetDateScan("dmy")), when inserting or updating the row in GridCtrl through grid.WhenInsertRow() callback the function called:

SQL & ::Insert(MYTABLE)
(NAME, grid(NAME))
(DATE, grid(DATE));
grid(ID) = SQL.GetInsertedId();

goes wrong because although the date looks right in GridCtrl, it has been saved wrong in sqlite file.

Solution, not perfect but it works: I convert the Value String in a Value Date before inserting or updating in sqlite, so the last code would be:

SQL & ::Insert(MYTABLE)
(NAME, grid(NAME))
(DATE, FixDate(grid(DATE)));
grid(ID) = SQL.GetInsertedId();

where FixDate is defined:

Value FixDate(Value &val)
{
if (!val.IsNull()) {
if (!val.Is<Date>()) {
Date d;
StrToDate(d, val.ToString());
return d;
}
}
return val;
}

StrToDate cares of converting the String into a right Date considering the SetDateScan defined.

Comments?


Best regards
IƱaki

[Updated on: Tue, 26 August 2008 22:08]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Unicode character paste in GridCtrl
Next Topic: Hiding in GridCtrl. Special case.
Goto Forum:
  


Current Time: Tue May 14 02:34:57 CEST 2024

Total time taken to generate the page: 0.02336 seconds