Page 1 of 1

MySQL, conversion from Strings from Zeos 6.6.6 to Zeos 7

Posted: 16.04.2012, 20:27
by mmvisual
Now, I use the ZeosV7 SVN1159 FPC2.6
https://zeoslib.svn.sourceforge.net/svn ... gonhugeist

And I have make a upgrade from Zeos 6.6.6 to 7. In Zeos 6.6.6+MySQL was a bug and all Strings are doubled UTF8Encoded and wrong posted into the Database. (See MyPHPAdmin or MySQLWorkbech)
This mistake needs an update function to correct that bug. This function must everybody self programing for his database.

I have make it, here my code example:

Code: Select all

      q2 := TZQuery.Create(Self);
      q2.Connection := q.Connection;
      q.SQL.Text := 'BEGIN';
      q.ExecSQL;
      q.SQL.Text := 'SHOW TABLES';
      q.Open;
      While Not q.EOF Do // Seek for all tabels
      Begin
        q2.Close;
        q2.SQL.Text := 'SELECT * FROM ' + LowerCase(q.Fields[0].AsString);
        q2.Open;
        While Not q2.EOF Do // Seek for all Datalines
        Begin
          bOK := False;
          For i := 0 To q2.FieldCount - 1 Do // Seek for all colums
          Begin
            fi := q2.Fields[i];
            If fi.DataType In [ftString, ftMemo] Then
            Begin
              If Not bOK Then
                q2.Edit;
              bOK := True;
              fi.AsString := UTF8Decode(WideString(fi.AsString));
            end;
          end;
          If bOK Then
            q2.Post;
          q2.Next;
        end;
        q.Next;
      End;
      q.Close;
      q2.Close;
      q2.Free;
      q.SQL.Text := 'COMMIT';
      q.ExecSQL;
You only make this conversion one time with a update. After them you can see all Characters like üäöß right.

Have a lot of fun, regards Markus.

Posted: 16.04.2012, 20:42
by EgonHugeist
Thanks mmvisual,

for that hint. I must admit i never realised this bug and didn't wanted to beleave it. :x
Until i saw that 6.6.6 bug flawless with my own eyes. :shock:

Zeos7 becomes better and better 8) !

Markus, your workaround will be very useful for everybody i hope! :bash:

Michael