?
Solved

Memo Field

Posted on 2003-03-06
5
Medium Priority
?
412 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

770 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