Hi all,

I'm using TSQLQuery on SQLite in order to manipulation very long unicode strings (in tibetan).

On inserting there is no problem, everything in inserted correctly in the database, using this code, containing a SQLquery :

procedure ExecuteSQL(pRequete: string; pCommit: boolean);
  var
    conn: TSQLConnection;
    query: TSQLQuery;
begin
  query := TSQLQuery.Create(nil);
  try
    try
      conn := getConnection(_TypeConnection);
      query.DataBase := conn;
      query.UsePrimaryKeyAsKey:=false;

      query.SQL.clear;
      query.SQL.Add(pRequete);
      query.ExecSQL;
      // COMMIT de la transaction et ouvre une nouvelle transaction
      if (pCommit = true) then
         conn.Transaction.CommitRetaining;
      query.Close;
    finally
      query.Free;
      //conn.Free;
    end;
  except
    on E: Exception do
    ShowMessage(E.message);
  end;
end;

BUT when I try to get the values, also with a SQLQuery, if the value is not unicode (ascii characters) I can get more than 255 chars, but if it's unicode (tibetan) the returned value is always cut to 255 characters.

    conn: TSQLConnection;
    query: TSQLQuery;
    str: widestring;
    i, n: integer;
  begin
    query := TSQLQuery.Create(nil);
    try
      try
        conn := getConnection(_TypeConnection);
        query.DataBase := conn;
        query.UsePrimaryKeyAsKey:=false;
        query.SQL.Text := pRequest;
        query.Open;
        query.Last;
        pGrid.Clean;
        n := 1;

        pGrid.RowCount := query.RecordCount + 1;
        pGrid.ColCount := pHeaders.Count;
        pGrid.FixedCols := pNbFixedCols;

        for i := 0 to pHeaders.Count - 1 do
            pGrid.Cells[i,0] := pHeaders.ValueFromIndex[i];

        query.First;
        while not query.EOF do
        begin
          for i := 0 to pAttrs.Count - 1 do
          begin
                // HERE str is always cut
str := query.FieldByName(pAttrs.ValueFromIndex[i]).AsWideString;
            pGrid.Cells[i,n] := str;
          end;
          query.Next;
          n := n + 1;
        end;
        // ajuste les colonnes au contenu
        pGrid.AutoAdjustColumns;

      finally
        query.Free;
        //conn.Free;
      end;
    except
      on E: Exception do
      ShowMessage(E.message);
  end;

Would somebody explain my why the value is always cut and give me a solution ? because didn't find any explaination of the internet, and as it's working in one way but not the other.

Thank you very much for your answer.

Hugues MOISY

--
Utilisant le logiciel de courrier révolutionnaire d'Opera : http://www.opera.com/mail/

--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to