[Gambas-user] Grid View and Mysql Result, Time Data

Demosthenes Koptsis demosthenesk at ...626...
Fri Sep 18 20:20:45 CEST 2009


ok i got it.

Thanks!

2009/9/18 Benoît Minisini <gambas at ...1...>:
>> I have a gridview control and i fill it with values from a mysql
>> $RESULT with the next code
>>
>> PUBLIC SUB grdView_Data(Row AS Integer, Column AS Integer)
>>
>>   $Result.MoveTo(Row)
>>
>>   grdView.Data.Text = Str($Result[grdView.Columns[Column].Text])
>>
>> END
>>
>>
>> The problem now.
>> When value is Date with mysql format %Y-%m-%d
>> the gridview shows "00:00:00" instead "0000:00:00" when the value of
>> result is empty
>> and change the format to %m/%d/%Y.
>>
>>
>> For example see col4 which holds dates
>>
>> mysql> SELECT * FROM `table4`;
>> +------+------+------+------------+
>>
>> | col1 | col2 | col3 | col4       |
>>
>> +------+------+------+------------+
>>
>> |    1 |   11 |  111 | 2008-09-24 |  <- %Y-%m-%d
>> |    2 |   22 |  222 | 0000-00-00 |
>>
>> +------+------+------+------------+
>> 2 rows in set (0.00 sec)
>>
>> And gridview shows
>>
>> 09/24/08
>>
>> Why is this? Normally the gridview must get the string " 2008-09-24"
>>
>
> No. Gambas takes from MySQL the real date, and then you convert it to a string
> with the Str() function. The "mysql" program does the same thing, but uses its
> own "date to string" conversion functions.
>
> If you want the same format, instead of using Str() (which is the better IMHO,
> as it follows the system localization settings), do that:
>
>  grdView.Data.Text = Format($Result[grdView.Columns[Column].Text],
>                             "yyyy-mm-dd")
>
> Regards,
>
> --
> Benoît Minisini
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry® Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9-12, 2009. Register now!
> http://p.sf.net/sfu/devconf
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



-- 

Γεια χαρα σε όλους!!!

Regards,

Demosthenes Koptsis




More information about the User mailing list