Weird encoding behavior & Event-Loop

My situation:
I want to switch a webapp, which is already running with a SQLite DB, to MySQL.

I’ve made the connection, brought all the data from the SQLite DB to the MySQL DB and everything seems fine.

Now I’m about to rewrite my code to handle the MySQL specifications. One is the encoding. The Encoding of my DB and all of its tables and fields is UTF8.

I use this code to select a value :

         dim RS as RecordSet = Session.mDB.SQLSelect(QUERY)
          dim val as String = RS.IdxField(i).StringValue.DefineEncoding(Encodings.UTF8)

The error:
This all seems to work. But if I want to set the result into a textfield (for example) the following error occurs:

Unhandled RuntimeException
Message: The data could not be converted to text with this encoding.


If I handle it over the unhandledexception-event, I get a loop-event-error.

What can I do???

Try this after connecting to the database:

Db.SQLExecute("SET NAMES utf8")

It works!
Thank you!

But, what does this do?

The server doesn’t know anything about the encoding on the client side of a session. I assume that the server uses ASCII if not told otherwise, but I’m not sure.