?
Solved

Memo Field

Posted on 2003-03-06
5
Medium Priority
?
415 Views
Last Modified: 2010-04-04
I have a project linked to a dbtable which has four string fields and a blob field.

When writing to the table i use table.fieldbyname('String Field1').asstring:=edit1.text;

When reading i use edit1.text:=table.fieldbyname('String Field1').asstring;

What is the code used to read and write the text in a memo box to and from the blob field?
0
Comment
Question by:Al_Shepstone
5 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 120 total points
ID: 8080032
usualy using streams like

//get
var m : tmemorystream;
begin
  m := tmemorystream.create;
  try
    TBlobField(dataset.FieldByName('BlobFieldName')).SaveToStream(m);
    m.position := 0;
    memo1.lines.loadfromstream(m);
  finally
    m.free;
  end;
end;

//put
var m : tmemorystream;
begin
  m := tmemorystream.create;
  try
    memo1.lines.savetostream(m);
    m.position := 0;
    TBlobField(dataset.FieldByName('BlobFieldName')).LoadFromStream(m,ftMemo);  //dataset must be in editmode
  finally
    m.free;
  end;
end;

but why not use the TDBMemo-Control

meikl ;-)
0
 
LVL 1

Expert Comment

by:krukmat
ID: 8080099
 //writing from a memo
  astring:='';
  for i:= 0 to memo1.lines.count do
    astring:=astring + memo1.Lines[i];
  table1.fieldByName('afield').astring:=astring;
  //writing from a field to a memo
  memo1.lines.add(table1.fieldByName('afield').astring);
0
 
LVL 3

Expert Comment

by:ILE
ID: 8080147
instaead of using that metod for read and write much more easier is to link

stringfield with dbedit1 component

then u do not must to write eny code all will be automaticly

put one datasource on your form
put one dbedit or dbmemo component on your form

datasource1.dataset property set on your table or query component

dbedit1.datasource or dbmemo1.datasource set to datasource1

dbedit1.fieldname or dbmemo1.fieldname set to appropried fieldname chose from list



that will do all the job without single line of code



if u must associeted memo box then ask me again what u have and exlicitly what u wona do





0
 
LVL 3

Expert Comment

by:ILE
ID: 8080194
instaead of using that metod for read and write much more easier is to link

stringfield with dbedit1 component

then u do not must to write eny code all will be automaticly

put one datasource on your form
put one dbedit or dbmemo component on your form

datasource1.dataset property set on your table or query component

dbedit1.datasource or dbmemo1.datasource set to datasource1

dbedit1.fieldname or dbmemo1.fieldname set to appropried fieldname chose from list



that will do all the job without single line of code



if u must associeted memo box then ask me again what u have and exlicitly what u wona do





0
 

Author Comment

by:Al_Shepstone
ID: 8101352
The reason I don't want to use data aware components is the edit and memo boxes are getting the data from a Tquery, and i want to be able to edit the data and return it to the table.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …
Is your organization moving toward a cloud and mobile-first environment? In this transition, your IT department will encounter many challenges, such as navigating how to: Deploy new applications and services to a growing team Accommodate employee…
Suggested Courses

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question