[Gambas-user] make Label background from Database field

Doriano Blengino doriano.blengino at ...1909...
Sat Oct 17 19:59:38 CEST 2009


Dimitris Anogiatis ha scritto:
>  Vassili,
>
> Make sure there is data in the rsThesi!thesi field.
>
> Open a terminal, and login to mysql and do the Select statement from there
> and see if all the records have data on the thesi field.
>
> if not then you have to do something like this
>
> if isNull(rsThesi!thesi) = false then change_bgcolor("Label" &
> rsThesi!thesi)
>
> I hope this helps
>> I get error:
>> "Result is not available"
>> at line:
>> "change_bgcolor("Label" & rsThesi!thesi)"
>>
>> of the code:
>>
>> PUBLIC SUB Form_Open()
>>  DIM i AS Integer
>>  DIM rsThesi AS Result
>>     MODMain.Connect()
>>    rsThesi = MODMain.$Con.exec("select * from egrafes where elenchosAnax =
>> 0")
>>     rsThesi.MoveFirst
>>     WHILE rsThesi.Index < rsThesi.Count
>>      change_bgcolor("Label" & rsThesi!thesi)
>>       rsThesi.MoveNext
>>     WEND
>>    MODMain.$Con.Commit()
>> END
>>
>>     
There is something strange in here. If the SQL statement was incorrect, 
then an error should raise when executing it.
If the SQL returned an empty dataset, then rsThesi.Count should be 0, 
and rsThesi.Index should be 0 also. 0 is not less than 0, so the loop 
should not even execute... unless, on an empty dataset, Index is set to 
-1 (it would be *very* stupid). Try to test for data availability using 
rsThesi.Available, do some print (.Index, .count, .available) just 
before the loop. And let me know - I am curious...

If the dataset is not empty then the loop executes; if no field named 
"thesi" existed in table "engrafes", then the error "Result is not 
available" is misguiding.

Lastly, what is $con.Commit() for?

As Dimitris says, check the contents of your database using some tool 
(gambas database manager would be ok). Surely you will find something 
strange in there.

Regards,

-- 
Doriano Blengino

"Listen twice before you speak.
This is why we have two ears, but only one mouth."





More information about the User mailing list