- create a DB table
with ADConn.Params do begin
Clear;
Add('DriverID=SQLite');
Add('CharacterSet=utf8');
Add('OpenMode=CreateUTF8');
Add('PRAGMA encoding = "UTF-8"');
Add('Database='+exDir+'\data.db');
end;
ADConn.Connected := True;
//ADConn.ExecSQL('create table if not exists myinfo (vocab string, mean TEXT)'); // vocab not work on UTF8 encode = ???
ADConn.ExecSQL('create table if not exists myinfo (vocab TEXT, mean TEXT)'); // SQLite is Text only , correct UTF8 encode why not :P
ADConn.ExecSQL('create index vocab on dict(vocab ASC)');
ADT.TableName := 'myinfo';
ADT.Open();
---------------------------
- insert data into this table
ADT.FieldByName('vocab').Value:=AnsiToUtf8Ex(v,c); // convert with codepage
ADT.FieldByName('mean').Value:=AnsiToUtf8Ex(m,c);
-----------------------------
- fetch data from this table
do you mean query or read data?
if read data I use ADT.FieldByName('xxx').AsString;
for query,I juse solved on my query. it must use UTF8Encode(xxx)
but I sill confuse why AnsiToUtf8Ex(xx,xx) work on SQLite 'text' type field only.
ADT = table
ADQ = query
ADConn = connection
for AnyDAC
↧