Board index » delphi » Accessing a Paradox Memo field from a DLL

Accessing a Paradox Memo field from a DLL

All I want to do is access the memo field in a
Paradox 7 table - from a DLL (in D2).

The following works in an .exe file on a form:

var s:string;
begin
     if DBMemo1.Lines[0]<>'' then
        s:= DBMemo1.Lines[0];

but it bombs in my DLL.

DBMemo1 is created with

    DBMemo1:=TDBMemo.create(nil);

its DataField and DataSource are set:

    DBMemo1.DataField:= 'Description';
    DBMemo1.DataSource:= DataSource1;

DataSource1 is created and defined:

DataSource1:=TDataSource.create(nil);
DataSource1.DataSet:=Product;

Product is a Table that is defined properly - indeed,
it works fine for accessing all other fields.

I can't work out what I've done wrong.

Should the above work? - I still have some hair left, but
it's in danger!

(Using a DBMemo component just to access the memo field
is very inelegant, surely there's a simpler way? In an .exe
file s:=Product.Fields[2].asString; works - but not in my DLL
if the field isn't empty - even if only a 50 char string).

TIA

Paul
SoftStuff, Croydon, Victoria, Australia, 3136
pa...@linuxserver.pccity.com.au

 

Re:Accessing a Paradox Memo field from a DLL


Quote
Paul Motyer <pa...@linuxserver.pccity.com.au> writes:
> All I want to do is access the memo field in a
> Paradox 7 table - from a DLL (in D2).

> The following works in an .exe file on a form:

> var s:string;
> begin
>      if DBMemo1.Lines[0]<>'' then
>         s:= DBMemo1.Lines[0];

> but it bombs in my DLL.

<..snip..>

Quote

> I can't work out what I've done wrong.

> Should the above work? - I still have some hair left, but
> it's in danger!

> (Using a DBMemo component just to access the memo field
> is very inelegant, surely there's a simpler way? In an .exe
> file s:=Product.Fields[2].asString; works - but not in my DLL
> if the field isn't empty - even if only a 50 char string).

Article 11263   Accessing a Paradox Memo field from a DLL
Paul Motyer

SOLVED (sort of).

The error seems to be generated by the comparison.  Changing

if Product.Fields[2].asString)<>'' then ...

to:

if length(Product.Fields[2].asString)>0 then ....

works fine. Now, from a purely academic point of view, why does

if DBMemo1.Lines[0]<>'' then ...

or

if Product.Fields[2].asString)<>'' then ...

bomb (but only in the formless DLL)?  Maybe (gasp) it's a bug?

Paul            (Thurs, 2 May, 1996, 4:45 EST)
SoftStuff, Croydon, Victoria, Australia, 3136
pa...@linuxserver.pccity.com.au

Other Threads