I'am trying to convert a database with charset None to the same but in UTF8.
Source database = Firebird 3.0 charset None Dialect 1
Destination database = Firebirde 3.0 charset UTF8 Dialect 1
I use a TCRBatchMove component to do that.
But each time a field of the source database containing a special char like "é" or "à" I receive an "Malformed string" error and importation is aborted.
That I have tried :
1) Source database force to with TIBCConnection.Options.Charset=Win1252
2) Destination database TIBCConnection..Options.useUnicode=true or false
3) Destination database TIBCConnection.Options.Charset=NONE
4) This viewtopic.php?f=24&t=24630&p=83281
5) Trying to do :
Code: Select all
procedure TDataCharsetNoneToUTF8.Q_DestinationAfterOpen(DataSet: TDataSet);
var
i: Integer;
begin
for i := 0 to DataSet.FieldCount - 1 do
if DataSet.Fields[i] is TStringField then begin
DataSet.Fields[i].OnGetText := OnGetText;
DataSet.Fields[i].OnSetText := OnSetText;
end;
end;
My code is very simple and do something like that :
Code: Select all
CRBatchMove: TCRBatchMove;
Q_Source: TIBCQuery;
Q_Destination: TIBCQuery;
Base_Source: TIBCConnection;
Base_DestinationUTF8: TIBCConnection;
.../...
function TDataCharsetNoneToUTF8.GetTableList: Tstrings;
begin
if not assigned(FTableList) then
FTableList:=TStringList.Create;
if FTableList.count=0 then
begin
Base_Source.GetTableNames(FTableList);
end;
result:= FTableList;
end;
.../...
begin
for I := 0 to FTableList.Count-1 do
begin
Q_Source.Active:=false;
Q_destination.Active:=false;
Q_Source.MacroByName('TableName').Value:=FTableList[i];
Q_SourceCompte.Active:=false;
Q_SourceCompte.MacroByName('TableName').Value:=FTableList[i];
Q_SourceCompte.Active:=true;
Q_destination.MacroByName('TableName').Value:=FTableList[i];
try
Q_Source.Active:=True;
Q_destination.Active:=True;
CRBatchMove.Execute;
Q_destination.Transaction.CommitRetaining;
except
end;
end;
end;
Code: Select all
object CRBatchMove: TCRBatchMove
AbortOnKeyViol = False
AbortOnProblem = False
Destination = Q_Destination
Source = Q_Source
OnBatchMoveProgress = CRBatchMoveBatchMoveProgress
Left = 208
Top = 176
end
object Q_Source: TIBCQuery
Connection = Base_Source
SQL.Strings = (
'select * from &TableName')
AfterOpen = Q_DestinationAfterOpen
Left = 128
Top = 176
MacroData = <
item
Name = 'TableName'
end>
end
object Q_Destination: TIBCQuery
Connection = Base_DestinationUTF8
SQL.Strings = (
'select * from &TableName '
'where (0=1)')
Options.StrictUpdate = False
BeforePost = Q_DestinationBeforePost
OnPostError = Q_DestinationPostError
Left = 288
Top = 176
MacroData = <
item
Name = 'TableName'
end>
end
object Base_Source: TIBCConnection
Database = 'H:\data\DATABASESOURCE_NONE.FDB'
Options.Charset = 'NONE'
SQLDialect = 1
ClientLibrary = 'gds32.dll'
Port = '3050'
Username = 'sysdba'
Server = '192.168.1.101'
LoginPrompt = False
Left = 128
Top = 96
end
object Base_DestinationUTF8: TIBCConnection
Database = 'H:\data\DATABASESOURCE_UTF8.FDB'
Options.Charset = 'UTF8'
Options.UseUnicode = True
Options.NoDBTriggers = True
SQLDialect = 1
ClientLibrary = 'gds32.dll'
Port = '3050'
Username = 'sysdba'
Server = '192.168.1.101'
LoginPrompt = False
Left = 288
Top = 96
end
I use version 5.7.24 on Delphi XE.
Best regards,
Fabrice