Jump to content
Sign in to follow this  
xorpas

FireDac store Arabic characters as question marks (???)

Recommended Posts

 i have an issu with FireDac  it store  Arabic characters as  question marks (???)

code create database at runtime is 

var
  SQL: string;
  FConnection: TFDConnection;
begin
  FConnection := TFDConnection.Create(nil);
  FConnection.DriverName := 'SQLite';
  FConnection.Params.Add('OpenMode=CreateUTF8');
  FConnection.Params.Add('CharacterSet=UTF8');
  FConnection.Params.Database := DB;
  FConnection.Open;
  SQL := 'CREATE TABLE Contact (ID INTEGER PRIMARY KEY AUTOINCREMENT, Name TEXT, Phone TEXT, Img BLOB)';
  FConnection.Open;
  FConnection.ExecSQL(SQL);
  FConnection.Close;

and insert is 

Connection := TFDConnection.Create(nil);
  Connection.DriverName := 'SQLite';
  Connection.Params.Database := DB;
  Connection.Params.Add('OpenMode=CreateUTF8');
  Connection.Params.Add('CharacterSet=UTF8');
  Connection.Open;
  Query := TFDQuery.Create(nil);
  Query.Connection := Connection;
 
  begin
    Query.SQL.Text :=
      'INSERT INTO Contact (Name, Phone, Img) VALUES (:Name, :Phone, :Img)';
    if Param[0] = '' then
      exit;
    if Param[1] = '' then
      exit;
    begin
     Query.ParamByName('Name').AsString := (Param[0]);
      Query.ParamByName('Phone').AsString := Param[1];
      stream := TMemoryStream.Create;
      if Param[2] = 'nil' then
      begin

      end
      else
      begin
        stream.LoadFromFile(Param[2]);
        Query.ParamByName('Img').LoadFromStream(stream, ftBlob);
      end;

      Query.ExecSQL;
      stream.Free;
    end;

  end;

help to solve this issue

 

Untitled.png.0e0500aa76d2bd2e2cee5f47a13f7973.png

Share this post


Link to post

Hi, try this
 

Query.ParamByName('Name').AsWideString := ...

 

Regards

Edited by Andy.B
  • Thanks 1

Share this post


Link to post
11 hours ago, Andy.B said:

Hi, try this
 


Query.ParamByName('Name').AsWideString := ...

 

Regards

Best regards it work now thank you for reply mr andy

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×