In non Unicode Delphi version, The basics are that you need to work with WideString
s (Unicode) instead of String
s (Ansi).
Forget about TADOQuery.SQL
(TStrings), and work with TADODataSet.CommandText
or TADOCommand.CommandText
(WideString) or typecast TADOQuery
as TADODataSet
. e.g:
stlTemp: TWideStringList; // <- Unicode strings - TNT or other Unicode lib
qry: TADOQuery;
stQuery: WideString; // <- Unicode string
TADODataSet(qry).CommandText := stQuery;
RowsAffected := qry.ExecSQL;
You can also use TADOConnection.Execute(stQuery)
to execute queries directly.
Be extra careful with Parametrized queries: ADODB.TParameters.ParseSQL
is Ansi. If ParamCheck
is true (by default) TADOCommand.SetCommandText
->AssignCommandText
will cause
problems if your Query is Unicode (InitParameters
is Ansi).
(note that you can use ADO Command.Parameters
directly - using ?
chars as placeholder for the parameter instead of Delphi's convention :param_name
).
QuotedStr
returns Ansi string. You need a Wide version of this function (TNT)
Also, As @Arioch 'The mentioned TNT Unicode Controls
suite is your best fried for making Delphi Unicode application.
It has all the controls and classes you need to successfully manage Unicode tasks in your application.
In short, you need to think Wide :)