Charset problem on grid after successful SQL SELECT
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 18
- Joined: Sat Mar 01, 2014 10:35 pm
Charset problem on grid after successful SQL SELECT
I am starting to use LiveCode with MySQL. My database has a single table (it's a begin), containing textfields. My computer is a Mac and I am coming from Windows and MS/Access.
To transport the database, I exported the final join as a single table on CSV format and imported it to MySQL. The table content looks perfect when viewing though MySQL Workbench. then I did set up a grid on a stack and it looks great except than, through the grid, all accented characters and replaced by weird characters. The database is UFT-8 (previously was "latin1" but now I have changed all to UFT-8.
Can anyone help?
To transport the database, I exported the final join as a single table on CSV format and imported it to MySQL. The table content looks perfect when viewing though MySQL Workbench. then I did set up a grid on a stack and it looks great except than, through the grid, all accented characters and replaced by weird characters. The database is UFT-8 (previously was "latin1" but now I have changed all to UFT-8.
Can anyone help?
Re: Charset problem on grid after successful SQL SELECT
First, override the standard behavior of your datagrid by following this lesson :
http://lessons.runrev.com/s/lessons/m/d ... -to-a-cell
Then in the behavior script, change the FillInData script with :
This will display correctly UTF8 strings in your datagrid, provided you retrieve UTF8 data from your SQL query.
Last but not least, you could try to play with the charset of MySQL by executing this command, BEFORE to do your SELECT.
http://lessons.runrev.com/s/lessons/m/d ... -to-a-cell
Then in the behavior script, change the FillInData script with :
Code: Select all
on FillInData pData
-- This message is sent when the Data Grid needs to populate
-- this template with the column data. pData is the value to be displayed.
set the unicodetext of the long ID of me to uniencode(pData, "utf8")
end FillInData
Last but not least, you could try to play with the charset of MySQL by executing this command, BEFORE to do your SELECT.
Code: Select all
revExecuteSQL dbID, "SET NAMES 'utf8'"
-
- Posts: 18
- Joined: Sat Mar 01, 2014 10:35 pm
Re: Charset problem on grid after successful SQL SELECT
Ok. I'll try do do it immediatly.
-
- Posts: 18
- Joined: Sat Mar 01, 2014 10:35 pm
Re: Charset problem on grid after successful SQL SELECT
Gee! Thanks! It works perfectly!
Please let me know it I am interpreting in the right manner what you suggested:
1. create an object (aka a button) that will contain the predefined behaviour of another object, in this case, a grid (my grid name is "DataT")
2. point in the grid object (DataT) the standard behaviour to the behaviour programmed in the new object (thus the new FillInData code) and do that in the Message Box
Two questions arose:
1. can I avoid the Message Box command and put that in the code itself at application launch?
2. Sort order: something wend wrong and the sort order is not perfect. I am attaching a sample where "Suleimane" comes AFTER "Sábado" and it should be the opposite. How can I do to correct it?
Please let me know it I am interpreting in the right manner what you suggested:
1. create an object (aka a button) that will contain the predefined behaviour of another object, in this case, a grid (my grid name is "DataT")
2. point in the grid object (DataT) the standard behaviour to the behaviour programmed in the new object (thus the new FillInData code) and do that in the Message Box
Two questions arose:
1. can I avoid the Message Box command and put that in the code itself at application launch?
2. Sort order: something wend wrong and the sort order is not perfect. I am attaching a sample where "Suleimane" comes AFTER "Sábado" and it should be the opposite. How can I do to correct it?
Re: Charset problem on grid after successful SQL SELECT
Yes for both.jlspereira wrote: 1. create an object (aka a button) that will contain the predefined behaviour of another object, in this case, a grid (my grid name is "DataT")
2. point in the grid object (DataT) the standard behaviour to the behaviour programmed in the new object (thus the new FillInData code) and do that in the Message Box
No need. The modification made on the datagrid IS SAVEDjlspereira wrote: 1. can I avoid the Message Box command and put that in the code itself at application launch?

Sorting problems with UTF8 in datagrid ?... hum... that's beyond my competence.jlspereira wrote: 2. Sort order: something wend wrong and the sort order is not perfect. I am attaching a sample where "Suleimane" comes AFTER "Sábado" and it should be the opposite. How can I do to correct it?
I think you should handle the problem in your query, at the MySQL server level.
Read this :
http://stackoverflow.com/questions/8782 ... r-ordering
Example : .....
Code: Select all
ORDER BY mycolumn COLLATE utf8_persian_ci
-
- Posts: 18
- Joined: Sat Mar 01, 2014 10:35 pm
Re: Charset problem on grid after successful SQL SELECT
Nope... The data grid itself sorts out if I click on the column. I must go through the data grid (anyway I started with your suggestion but it failed when re-sorting)
Thanks for the help because the crucial problem is now solved by you. The reason to put the code at open stack was to make sure that in future applications I am treating well the character set issue.
Now I am going to a data grid form to sort out the other problems
thanks again
Joao
Thanks for the help because the crucial problem is now solved by you. The reason to put the code at open stack was to make sure that in future applications I am treating well the character set issue.
Now I am going to a data grid form to sort out the other problems
thanks again
Joao