Hello,
I have a SQLite database which contains unicode (NVARCHAR, NTEXT) and non-unicode (VARCHAR, TEXT) fields.
Now I would like to access these fields as TStringField or TWideStringField - as required.
How can I archieve this?
When I set UseUnicode to True, all the fields are treated as UniCode fields.
When I set UseUnicode to False, all the fields are treated as non unicode fields.
Thanks for your support.
Bye,
Jürgen
Mixed fields with SQLite
Re: Mixed fields with SQLite
That's true, the described behavior will be defined by the value of the UseUnicode property. However, you can change it for each field you are interested in separately using DataTypeMapping: https://www.devart.com/unidac/docs/data ... apping.htm
For example:
For example:
Code: Select all
uses LiteDataTypeMapUni;
...
UniQuery.DataTypeMap.AddFieldNameRule('VARCHARFIELD', ftString, 1024);
UniQuery.DataTypeMap.AddFieldNameRule('NVARCHARFIELD', ftWideString, 1024);
-
- Posts: 4
- Joined: Fri 13 Jul 2018 09:54
Re: Mixed fields with SQLite
With this mappings, I have to define the field size too. Which is not useable.
Why do not map NVARCHAR fields -> ftWideString
and VARCHAR field-> ftString
as defined in the database?
Why do not map NVARCHAR fields -> ftWideString
and VARCHAR field-> ftString
as defined in the database?
Re: Mixed fields with SQLite
When adding the DataTypeMapping rule, you do not need to explicitly set the field size value. In this case, the size of the created test field will be determined by the value specified in the DB when it is created. For example, for the TESTTABLE table ( ), you can specify the following rule:
In this case, the size of the created field of ftString type will equal 38
Code: Select all
CREATE TABLE TESTTABLE (NAME VARCHAR(38))
Code: Select all
UniQuery.DataTypeMap.AddFieldNameRule('NAME', ftString);