TEXT shows as (WIDEMEMO) in DBGrid

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

TEXT shows as (WIDEMEMO) in DBGrid

larshgf
Hi,
I am using Delphi 10.1 and I am trying to learn how to handle FireDAC with
SQLite as a database. Beeing used to ADO and Access I find the learning
curve a bit steep!

My simple project:
I have build a simple SQLite database with only 2 fields: a primary key
integer and a text field, like this:

CREATE TABLE gms(
gms_id INTEGER PRIMARY KEY,
gms_verb TEXT NOT NULL
);

I have placed FDConnection, FDTable and DataSource + DBGrid and DBNavigator.
An Edit and a button with this OnClick code:

procedure TForm1.Button1Click(Sender: TObject);
begin
FDTable1.Append;
FDTable1.FieldByName('gms_verb').AsString:= Edit1.Text;
FDTable1.Post;
end;

But when I put a string in the table 'gms_verb' I only get the primary key
number - the string is shown like (WIDEMEMO).

Any explanation of this?

Best Regards
Lars

 

 

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: TEXT shows as (WIDEMEMO) in DBGrid

Clemens Ladisch
Lars Frederiksen wrote:

> CREATE TABLE gms(
> gms_id INTEGER PRIMARY KEY,
> gms_verb TEXT NOT NULL
> );
>
> FDTable1.Append;
> FDTable1.FieldByName('gms_verb').AsString:= Edit1.Text;
> FDTable1.Post;
>
> But when I put a string in the table 'gms_verb' I only get the primary key
> number - the string is shown like (WIDEMEMO).

In SQLite, all text values are Unicode and can have an arbitrary size, so
dtWideMemo is what FireDAC thinks is the best match.

You could use a different type name, or set up a type mapping:
http://docwiki.embarcadero.com/RADStudio/XE7/en/Using_SQLite_with_FireDAC#SQLite_Data_Types


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: TEXT shows as (WIDEMEMO) in DBGrid

larshgf
Thank you Clemens!

I am trying to learn FireDAC and SQLite, indeed a steep learning curve!
I just realized that it is possible to replace TEXT with VARCHAR(). I have followed 2 tutorials about SQLite, and none of these mentioned the VARCHAR() possibility....
But I also realized that it is not possible just to put some greek (unicode) characters into a field. It ends up with a mix of latin chars and questionmarks.
Is there a (simple) solution on this problem?

Regards
Lars

-----Oprindelig meddelelse-----
Fra: sqlite-users [mailto:[hidden email]] På vegne af Clemens Ladisch
Sendt: 7. august 2017 08:33
Til: [hidden email]
Emne: Re: [sqlite] TEXT shows as (WIDEMEMO) in DBGrid

Lars Frederiksen wrote:

> CREATE TABLE gms(
> gms_id INTEGER PRIMARY KEY,
> gms_verb TEXT NOT NULL
> );
>
> FDTable1.Append;
> FDTable1.FieldByName('gms_verb').AsString:= Edit1.Text; FDTable1.Post;
>
> But when I put a string in the table 'gms_verb' I only get the primary
> key number - the string is shown like (WIDEMEMO).

In SQLite, all text values are Unicode and can have an arbitrary size, so dtWideMemo is what FireDAC thinks is the best match.

You could use a different type name, or set up a type mapping:
http://docwiki.embarcadero.com/RADStudio/XE7/en/Using_SQLite_with_FireDAC#SQLite_Data_Types


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: TEXT shows as (WIDEMEMO) in DBGrid

Hick Gunter
Von: sqlite-users [mailto:[hidden email]] Im Auftrag von Lars Frederiksen
Gesendet: Montag, 07. August 2017 09:00
An: 'SQLite mailing list' <[hidden email]>
Betreff: Re: [sqlite] TEXT shows as (WIDEMEMO) in DBGrid

...
But I also realized that it is not possible just to put some greek (unicode) characters into a field. It ends up with a mix of latin chars and questionmarks.
Is there a (simple) solution on this problem?

...

This is most probably caused by inserting UTF encoded characters into an ISO string and then performing an ISO to UTF translation, or vice versa, somewhere outside of SQLite.

SQLite will assume that any string passed in is UTF coded and faithfully reproduce whatever was passed in. The only conversions that happen are when you explicitly convert among UTF8, UTF16BE and UTF16LE.


___________________________________________
 Gunter Hick
Software Engineer
Scientific Games International GmbH
FN 157284 a, HG Wien
Klitschgasse 2-4, A-1130 Vienna, Austria
Tel: +43 1 80100 0
E-Mail: [hidden email]

This communication (including any attachments) is intended for the use of the intended recipient(s) only and may contain information that is confidential, privileged or legally protected. Any unauthorized use or dissemination of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender by return e-mail message and delete all copies of the original communication. Thank you for your cooperation.


_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: TEXT shows as (WIDEMEMO) in DBGrid

Clemens Ladisch
In reply to this post by larshgf
Lars Frederiksen wrote:
> I have followed 2 tutorials about SQLite, and none of these mentioned the VARCHAR() possibility....

Because SQLite pretty much ignores column types.
Interpreting "VARCHAR" this way is how FireDAC does things; you have to look
into the FireDAC documentation.

> But I also realized that it is not possible just to put some greek (unicode) characters into a field. It ends up with a mix of latin chars and questionmarks.
> Is there a (simple) solution on this problem?

Yes: fix the bugs in your code (which you have not shown).


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: TEXT shows as (WIDEMEMO) in DBGrid

larshgf
Hi,

My code is simple. FDConnection, FDQuery, DataSource + DBGrid, 3 Edits and a button. Then this OnClick event:

Procedure TForm1.Button1Click(Sender: TObject);
begin
  FDTable1.Open;
  FDTable1.Append;
  FDTable1.FieldByName('gms_id').AsInteger:= StrToInt(edNummer.Text);
  FDTable1.FieldByName('gms_graesk').AsString:= edGræsk.Text; // this is greek letters but in DBGrid it is something like '?e? e??ae ?a???'
  FDTable1.FieldByName('gms_dansk').AsString:= edDansk.Text;
  FDTable1.Post;
end;

Regards
Lars

-----Oprindelig meddelelse-----
Fra: sqlite-users [mailto:[hidden email]] På vegne af Clemens Ladisch
Sendt: 7. august 2017 10:28
Til: [hidden email]
Emne: Re: [sqlite] TEXT shows as (WIDEMEMO) in DBGrid

Lars Frederiksen wrote:
> I have followed 2 tutorials about SQLite, and none of these mentioned the VARCHAR() possibility....

Because SQLite pretty much ignores column types.
Interpreting "VARCHAR" this way is how FireDAC does things; you have to look into the FireDAC documentation.

> But I also realized that it is not possible just to put some greek (unicode) characters into a field. It ends up with a mix of latin chars and questionmarks.
> Is there a (simple) solution on this problem?

Yes: fix the bugs in your code (which you have not shown).


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: TEXT shows as (WIDEMEMO) in DBGrid

Hick Gunter
It would be so much easier if you could provide hex dumps of the strings involved. Maybe just a few characters and a verbal description of what you think you are storing (greek lowercase alpha, ...).

From appearances it seems that your text objects are locale aware, which would suggest a code-page based approach instead of UTF8. Hint: If what you put in is all special characters and half as long as what is returned, then you are converting ISO to UTF8 somewhere along the way.

-----Ursprüngliche Nachricht-----
Von: sqlite-users [mailto:[hidden email]] Im Auftrag von Lars Frederiksen
Gesendet: Montag, 07. August 2017 10:39
An: 'SQLite mailing list' <[hidden email]>
Betreff: Re: [sqlite] TEXT shows as (WIDEMEMO) in DBGrid

Hi,

My code is simple. FDConnection, FDQuery, DataSource + DBGrid, 3 Edits and a button. Then this OnClick event:

Procedure TForm1.Button1Click(Sender: TObject); begin
  FDTable1.Open;
  FDTable1.Append;
  FDTable1.FieldByName('gms_id').AsInteger:= StrToInt(edNummer.Text);
  FDTable1.FieldByName('gms_graesk').AsString:= edGræsk.Text; // this is greek letters but in DBGrid it is something like '?e? e??ae ?a???'
  FDTable1.FieldByName('gms_dansk').AsString:= edDansk.Text;
  FDTable1.Post;
end;

Regards
Lars

-----Oprindelig meddelelse-----
Fra: sqlite-users [mailto:[hidden email]] På vegne af Clemens Ladisch
Sendt: 7. august 2017 10:28
Til: [hidden email]
Emne: Re: [sqlite] TEXT shows as (WIDEMEMO) in DBGrid

Lars Frederiksen wrote:
> I have followed 2 tutorials about SQLite, and none of these mentioned the VARCHAR() possibility....

Because SQLite pretty much ignores column types.
Interpreting "VARCHAR" this way is how FireDAC does things; you have to look into the FireDAC documentation.

> But I also realized that it is not possible just to put some greek (unicode) characters into a field. It ends up with a mix of latin chars and questionmarks.
> Is there a (simple) solution on this problem?

Yes: fix the bugs in your code (which you have not shown).


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


___________________________________________
 Gunter Hick
Software Engineer
Scientific Games International GmbH
FN 157284 a, HG Wien
Klitschgasse 2-4, A-1130 Vienna, Austria
Tel: +43 1 80100 0
E-Mail: [hidden email]

This communication (including any attachments) is intended for the use of the intended recipient(s) only and may contain information that is confidential, privileged or legally protected. Any unauthorized use or dissemination of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender by return e-mail message and delete all copies of the original communication. Thank you for your cooperation.


_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: TEXT shows as (WIDEMEMO) in DBGrid

larshgf
Hi Gunter and Clemens!

Thank you for your help. I appears that the Connection Editor in FDConnection has a StringFormat property and after setting this to Unicode the problem was solved.

Regards
Lars

-----Oprindelig meddelelse-----
Fra: sqlite-users [mailto:[hidden email]] På vegne af Hick Gunter
Sendt: 7. august 2017 10:47
Til: 'SQLite mailing list'
Emne: Re: [sqlite] TEXT shows as (WIDEMEMO) in DBGrid

It would be so much easier if you could provide hex dumps of the strings involved. Maybe just a few characters and a verbal description of what you think you are storing (greek lowercase alpha, ...).

From appearances it seems that your text objects are locale aware, which would suggest a code-page based approach instead of UTF8. Hint: If what you put in is all special characters and half as long as what is returned, then you are converting ISO to UTF8 somewhere along the way.

-----Ursprüngliche Nachricht-----
Von: sqlite-users [mailto:[hidden email]] Im Auftrag von Lars Frederiksen
Gesendet: Montag, 07. August 2017 10:39
An: 'SQLite mailing list' <[hidden email]>
Betreff: Re: [sqlite] TEXT shows as (WIDEMEMO) in DBGrid

Hi,

My code is simple. FDConnection, FDQuery, DataSource + DBGrid, 3 Edits and a button. Then this OnClick event:

Procedure TForm1.Button1Click(Sender: TObject); begin
  FDTable1.Open;
  FDTable1.Append;
  FDTable1.FieldByName('gms_id').AsInteger:= StrToInt(edNummer.Text);
  FDTable1.FieldByName('gms_graesk').AsString:= edGræsk.Text; // this is greek letters but in DBGrid it is something like '?e? e??ae ?a???'
  FDTable1.FieldByName('gms_dansk').AsString:= edDansk.Text;
  FDTable1.Post;
end;

Regards
Lars

-----Oprindelig meddelelse-----
Fra: sqlite-users [mailto:[hidden email]] På vegne af Clemens Ladisch
Sendt: 7. august 2017 10:28
Til: [hidden email]
Emne: Re: [sqlite] TEXT shows as (WIDEMEMO) in DBGrid

Lars Frederiksen wrote:
> I have followed 2 tutorials about SQLite, and none of these mentioned the VARCHAR() possibility....

Because SQLite pretty much ignores column types.
Interpreting "VARCHAR" this way is how FireDAC does things; you have to look into the FireDAC documentation.

> But I also realized that it is not possible just to put some greek (unicode) characters into a field. It ends up with a mix of latin chars and questionmarks.
> Is there a (simple) solution on this problem?

Yes: fix the bugs in your code (which you have not shown).


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


___________________________________________
 Gunter Hick
Software Engineer
Scientific Games International GmbH
FN 157284 a, HG Wien
Klitschgasse 2-4, A-1130 Vienna, Austria
Tel: +43 1 80100 0
E-Mail: [hidden email]

This communication (including any attachments) is intended for the use of the intended recipient(s) only and may contain information that is confidential, privileged or legally protected. Any unauthorized use or dissemination of this communication is strictly prohibited. If you have received this communication in error, please immediately notify the sender by return e-mail message and delete all copies of the original communication. Thank you for your cooperation.


_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Loading...