Board index » delphi » LoadFromFile (D2)

LoadFromFile (D2)

Hi!

I need to get the contents from a file into a memo field.
I've tried this:

MyTable.FieldByName('notes').loadFromFile('text.txt');

This wont work. I get an error.
How is the correct way to do this?
Can someone be kind to help me out with this? Maby an example?

-Geir Bratlie-

 

Re:LoadFromFile (D2)


Quote
Geir Bratlie wrote:

> Hi!

> I need to get the contents from a file into a memo field.
> I've tried this:

> MyTable.FieldByName('notes').loadFromFile('text.txt');

> This wont work. I get an error.
> How is the correct way to do this?
> Can someone be kind to help me out with this? Maby an example?

> -Geir Bratlie-

Try using a DBMemo component (e.g., DBMemo1) and...
        DBMemo1.lines.loadfromfile('text.txt');

Re:LoadFromFile (D2)


Quote
Chuck Hall wrote:

> Geir Bratlie wrote:

> > Hi!

> > I need to get the contents from a file into a memo field.
> > I've tried this:

> > MyTable.FieldByName('notes').loadFromFile('text.txt');

> > This wont work. I get an error.
> > How is the correct way to do this?
> > Can someone be kind to help me out with this? Maby an example?

> > -Geir Bratlie-
> Try using a DBMemo component (e.g., DBMemo1) and...
>         DBMemo1.lines.loadfromfile('text.txt');

Typecasting the field on the table as a TMemoField will also work.

(MyTable.FieldByName('notes') As TMemoField).LoadFromFile('text.txt');

I find this a bit cleaner than dropping hidden memo controls onto my
interface. Although in a pinch the hidden memo approach works deviously
well.

Andrew Martin
Programmer
Stone Micro Designs, Inc.
Come and see the Delphi components we've made at:
http://www.stonemicrodesigns.com/smdhome.htm

Other Threads