Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 08-07-2017, 05:05 AM
larshgf larshgf is offline
Senior Member
 
Join Date: Jan 2001
Posts: 236
Default DBGrid with WIDEMEMO

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
Reply With Quote
  #2  
Old 08-07-2017, 07:22 PM
rojam rojam is offline
Senior Member
 
Join Date: Jun 2015
Posts: 166
Default

Don't use a FDTable, use a query component instead and select the substring of gms_verb.

substr(gms_verb, 1, <#of char to return>)

set the sql property of the query to something like:

Code:
select gms_id, substr(gms_verb, 1, 50) as gms_verb from gms order by 2;
Reply With Quote
  #3  
Old 08-07-2017, 08:05 PM
larshgf larshgf is offline
Senior Member
 
Join Date: Jan 2001
Posts: 236
Default

Hi Rojam,

Thank you for your answer. Interesting solution. But how do I do that when I want my DBGrid to show the string? Do you have a piece of code?
In the meantime i realized that using VARCHAR(50) etc instead of TEXT will show the string correctly.
But I will try your solution too and in fact I am going to replace FDTable with FDQuery as it should be more flexible.

Regards
Lars

Last edited by larshgf; 08-08-2017 at 11:10 AM.
Reply With Quote
Reply

Tags
berlin, dbgrid, firedac, sqlite, widedemo

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 09:58 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2017, vBulletin Solutions, Inc.