Page 1 of 1
Get Trash Instead Umlaut letter from DB.
Posted: Wed 14 Mar 2012 16:34
by Sergii
Hello. I have DB with umlaut letters. Db is MySQL 3.23.45. Default charset is latin1. When I get data using Devart dotConnect. I get trash instead umlaut letter.
What I should change to get valid letters?
I was trying to change charset in connection string to latin1. It is not help, I get exception "Client character set 'utf8' is different from server character set 'latin1'.".
If change to utf8 It gets exception. I was trying set Unicode=true in connection string and in connection object in code. But I get exception like "Client character set 'utf8' is different from server character set 'latin1'."
How to read umlaut letter?
P.S. Server Explorer in VS2010 not read umlaut letters too when I use dotConnect.
Posted: Thu 15 Mar 2012 10:48
by Shalex
Synchronization of client and server encoding could be made by setting the Charset property of the MySqlConnection object (or the Character Set option in the connection string) to 'auto'. In this case, the server asks for the charset and sets the appropriate charset on the client. Does it help?
Posted: Thu 15 Mar 2012 12:48
by Sergii
At this moment I should say I have two DB on that server.
The first has Client CharacterSet = default.
The second Client CharacterSet = utf8;
I put Character Set = auto to each connection string.
Now I get valid data from first DB.
From second DB I still get trash.
Posted: Thu 15 Mar 2012 13:16
by Sergii
I think I know how to fix problem with second DB. It is my DB. And I will recreate it with default charset then I will copy from second DB to this one new.
Posted: Thu 15 Mar 2012 15:57
by Shalex
Sergii wrote:I think I know how to fix problem with second DB. It is my DB. And I will recreate it with default charset then I will copy from second DB to this one new.
We think that this will solve the issue.
Posted: Fri 16 Mar 2012 11:55
by Sergii
Thank you for Help. The problem solved.
special german chars umlaut
Posted: Tue 03 Apr 2012 18:17
by Denker
Hello,
i try this
http://www.devart.com/forums/viewtopic.php?t=23624
but it doesn`t help with mysqldump or mysqlscript.
I use mysqldump to backup a file in the file all characters ok. I can connect to the same server and try to restore and the letters are not ok.
Mysqlloader have no problem.
I use Mysql Server Version 4.0.24.
Thank you for help
Posted: Wed 04 Apr 2012 13:42
by Pinturiccio
Please make sure that you use the ConnectionString parameter with 'Unicode=true' for the connection you use for Dump.Restore();
Could you please specify the character_set and character_sets values by executing the SQL query 'show variables like 'char%'?
Posted: Wed 04 Apr 2012 15:11
by Denker
Hi,
show variables like 'char%'
charset latin1
charsets latin1 big5 czech euc_kr gb2312 gbk latin1_de sjis tis620 ujis dec8 dos german1 hp8 koi8_ru latin2 swe7 usa7 cp1251 danish hebrew win1251 estonia hungarian koi8_ukr win1251ukr greek win1250 croat cp1257 latin5
if i try unicode = true i got an exception, charset differs from the server, set charset to latin1.
thanks
Denker
Posted: Thu 05 Apr 2012 13:18
by Pinturiccio
Could you please specify the following:
1. Your system default charset (it can be found with the help of the toolbar -> Region and Language on the Administrative tab. The language is specified on this tab in the Current language for non-Unicode programs section);
2. Both of your connection strings (roughly, without credentials) for backup and restore;
3. The snippet of code where you perform backing up;
4. The snippet of code where you perform restoring. Do you use the name of a file or a Stream object?
If you perform the backup and restoring with one connection in the same application do you have "all characters ok" in the file and "the letters are not ok" in the database after restoring?
Posted: Mon 09 Apr 2012 10:10
by Denker
sry that was my fault, i used streamreader and streamwriter to edit the File, and there was my fault, that the streamreader and streamwriter used a wrong encoding text. now it`s all ok.
I edit the file, so i can replace or ignore duplicate id, and now it`s ok.
Thank you
Code: Select all
Public Function tabellensync(ByVal table As String, Optional ByVal whereklausel As String = "", Optional ByVal auswahl As String = "*", Optional ByVal ignore As String = " IGNORE ") As Boolean
Dim sr As System.IO.StreamReader
Dim sw As System.IO.StreamWriter
Dim neu As String
Dim datei As String
datei = "C:\ticket_sync\" & table & Now.Ticks & ".sql"
tabellensync = True
dumpsave.IncludeDrop = True
dumpsave.GenerateHeader = True
dumpsave.Connection = conentfernt
dumpsave.UseExtSyntax = True
dumpsave.QuoteIdentifier = True
dumpsave.BackupQuery("select " & auswahl & " from " & table & " " & whereklausel, datei)
sr = New System.IO.StreamReader(datei)
neu = sr.ReadToEnd
sr.Close()
'with ignore i ignore duplicate id`s and with the second i Replace duplicate
then is ignore = " REPLACE "
If ignore = " IGNORE " Then
neu = Replace(neu, "INSERT INTO", "INSERT " & ignore & " INTO")
Else
neu = Replace(neu, "INSERT INTO", ignore & " INTO")
End If
sw = New System.IO.StreamWriter(datei)
sw.Write(neu)
sw.Close()
conlokal.open()
AddHandler dumpeinspiel.[Error], New Devart.Common.ScriptErrorEventHandler(AddressOf dump_error)
dumpeinspiel.Connection = conlokal
dumpeinspiel.Restore(datei)
My.Computer.FileSystem.DeleteFile(datei)
Return 1
End Function