[Gambas-user] datefields revisited

Steven Lobbezoo steven at ...1652...
Wed May 23 20:39:32 CEST 2007


Well You allso be drunk, or play with your new footbal, or ... whatever ;-)
Seriously : point well taken , i'll redo my code (sighh)
Thanks,
Steven




Le lundi 21 mai 2007 21:05, Benoit Minisini a écrit :
> On dimanche 20 mai 2007, Steven Lobbezoo wrote:
> > Hi Benoit,
> >
> > Did you have time to take a look at my problem ?
> >
> >
> > Steven
>
> When I don't answer, it is usually because I don't have the time :-)
>
> Well, there are a lot of horrible things in your code.
>
> Your problem comes from the fact that you don't read and write dates the
> same way.
>
> To read the date, you use the Gambas Result object that returns a date, and
> the Str$() function that converts the date to its *localized* string full
> representation.
>
> But when writing the date, you make yourself the SQL request, by using a
> syntax that is not necessarily correct.
>
> You must know that SQL is a standard like Microsoft is a charity compagny.
> In other words, its syntax mainly depends on the underlying database
> system. And so I designed the gb.db component to find a workaround.
>
> And so you must use the "quoting" feature of the DB.Exec() method. Each
> time you must insert a value in a SQL request (a number, a date, a
> string...), you must use the "&X" string, where X is the index of the
> value, and then you pass the value as parameters to the Exec() method.
>
> For example, you must not do:
>
> DB.Exec("UPDATE Ventes SET Date = \"10/2/2007\" WHERE Id = 123456")
>
> But:
>
> DB.Exec("UPDATE Ventes SET Date = &1 WHERE Id = &2", TheDate, TheID)
>
> In your specific case, when everything is made dynamically, you must use
> the DB.Quote() function, that takes any value, and returns its string
> presentation in the format of the underlying database system.
>
> Finally, your date problem comes from the fact that usually SQL does not
> take a localized format of the date, but an american one.
>
> A last point: it is useless and slower to do
> Object.SetProperty(ctrl, "Tag", "xxx"). Just do ctrl.Tag = "xxx". If, of
> course, ctrl is an instance of a class that has a Tag property.
>
> Do not hesitate to read the documentation on the wiki.
>
> Regards,




More information about the User mailing list