mysql forgets default charset after reconnect lazarus / 16-Databases ---------------------------------------------------------------------- mirce.vladimirov · 2015-03-15 00:52 My application is developed and runs on windows with lazarus 1.0.2. Server is Linux, MySQL on server is 5.1.46. After connect i do this : Code: [Select]procedure TfGlavnoMeni.MySQL50Connection1AfterConnect(Sender: TObject); begin  SQLQuery1.Close;  SQLQuery1.SQL.Clear;  SQLQuery1.SQL.Add('SET character_set_client = "UTF8", character_set_connection = "CP1251", character_set_results = "UTF8"');  SQLQuery1.ExecSQL; end;  For some reason Client computers are oftenly disconnected from the server (lost connection to MySQL server during query bla bla bla...) so i was reading this forum and other internet resources on that issue. I found this code and tried it : Code: [Select]    MySQL50Connection1.Connected:=true;     mysql_options(MySQL50Connection1.Handle, MYSQL_OPT_RECONNECT, 'true');and it works good, it does reconnect to the server, but after the reconnect all cyrillic data retrieved from the database are interpreted with "?", so i dont get the text. If i close my application an then start it again it works well which tells me that the "reconnect" part is where the rabbit hides. I added this : Code: [Select]    MySQL50Connection1.Connected:=true;     mysql_options(MySQL50Connection1.Handle, MYSQL_OPT_RECONNECT, 'true');     mysql_options(MySQL50Connection1.Handle, MYSQL_SET_CHARSET_NAME, 'utf8'); but nothing changed. ---------------------------------------------------------------------- mirce.vladimirov · 2015-03-15 01:09 I've just found that the procedure MySQL50Connection1AfterConnect  is executed only connect, and during recconect is not executed. ---------------------------------------------------------------------- mirce.vladimirov · 2015-03-15 01:22 This worked : go to Object Inspector->Params and add this : codepage=utf8 MYSQL_SET_CHARSET_NAME=UTF8 and that's it. Before I put this post under "solved" I should wait to see what happens in real working envirnonment usage ---------------------------------------------------------------------- LacaK · 2015-03-15 08:56 Quote from: mirce.vladimirov on March 15, 2015, 01:52:58 amCode: [Select]    MySQL50Connection1.Connected:=true;     mysql_options(MySQL50Connection1.Handle, MYSQL_OPT_RECONNECT, 'true');     mysql_options(MySQL50Connection1.Handle, MYSQL_SET_CHARSET_NAME, 'utf8'); but nothing changed. "mysql_options" must be called before "mysql_connect", so after connection is once activated it seems, that it has no effect ... Btw in trunk version of FPC is already possible set "CharSet" property of TMySQL50Connection, it will execute  "mysql_set_character_set"in background