Board index » delphi » Empty Memo causes crash w/ InterBase, Delphi 4

Empty Memo causes crash w/ InterBase, Delphi 4

1. I have Delphi 4 C/S along with the BDE, InterBase Client and InterBase
server that came with my Delphi 4 CD.

2. I add a BLOB field to the EMPLOYEE table in the IBLOCAL sample database
like so:

ALTER TABLE EMPLOYEE ADD NOTES BLOB SUB_TYPE 1

3. I create a new project in D4 and drop a TQuery with DatabaseName=IBLOCAL
and the following SQL:

UPDATE EMPLOYEE
SET SALARY=:SALARY, NOTES=:NOTES
WHERE EMP_NO=2

4. Then, I drop a TButton on the form and attach the following code:

Query1.ParamByName('SALARY').AsFloat := 100000;
Query1.ParamByName('NOTES').DataType := ftMemo;
Query1.ParamByName('NOTES').Clear;
Query1.ExecSQL;

5. I get an ACCESS VIOLATION when ExecSQL runs.

I was getting this with my applications where I was using a TUpdateSQL
component. I noticed that I got the EAccessViolation whenever I left my
comments field blank. If there is data in the comments field, then the query
runs fine. i.e. THIS WORKS:

Query1.ParamByName('SALARY').AsFloat := 100000;
Query1.ParamByName('NOTES').DataType := ftMemo;
List := TStringList.Create;
List.Add('Hello World');
Query1.ParamByName('NOTES').Assign(List);
List.Free;
Query1.ExecSQL;

(sigh)

I wish I knew what was happening. I've tried this on multiple workstations
(all running Windows NT 4.0 ws) and I've tried using a local server, TCP/IP
to a remote server, and NetBEUI to a remote server. Still have problems. I'm
going to try the program on a machine that has the old BDE 4.51 installed
and see what happens.

Does anyone have any ideas? This appears to be a bug. (btw, I have installed
the Delphi 4 patch)

TIA,

Dave Prothero
Director of R&D
Argos Software

 

Re:Empty Memo causes crash w/ InterBase, Delphi 4


Dave Prothero schrieb:

Quote
> 1. I have Delphi 4 C/S along with the BDE, InterBase Client and InterBase
> server that came with my Delphi 4 CD.

> 2. I add a BLOB field to the EMPLOYEE table in the IBLOCAL sample database
> like so:

> ALTER TABLE EMPLOYEE ADD NOTES BLOB SUB_TYPE 1

> 3. I create a new project in D4 and drop a TQuery with DatabaseName=IBLOCAL
> and the following SQL:

> UPDATE EMPLOYEE
> SET SALARY=:SALARY, NOTES=:NOTES
> WHERE EMP_NO=2

> 4. Then, I drop a TButton on the form and attach the following code:

> Query1.ParamByName('SALARY').AsFloat := 100000;
> Query1.ParamByName('NOTES').DataType := ftMemo;
> Query1.ParamByName('NOTES').Clear;
> Query1.ExecSQL;

> 5. I get an ACCESS VIOLATION when ExecSQL runs.

> I was getting this with my applications where I was using a TUpdateSQL
> component. I noticed that I got the EAccessViolation whenever I left my
> comments field blank. If there is data in the comments field, then the query
> runs fine. i.e. THIS WORKS:

> Query1.ParamByName('SALARY').AsFloat := 100000;
> Query1.ParamByName('NOTES').DataType := ftMemo;
> List := TStringList.Create;
> List.Add('Hello World');
> Query1.ParamByName('NOTES').Assign(List);
> List.Free;
> Query1.ExecSQL;

> (sigh)

> I wish I knew what was happening. I've tried this on multiple workstations
> (all running Windows NT 4.0 ws) and I've tried using a local server, TCP/IP
> to a remote server, and NetBEUI to a remote server. Still have problems. I'm
> going to try the program on a machine that has the old BDE 4.51 installed
> and see what happens.

> Does anyone have any ideas? This appears to be a bug. (btw, I have installed
> the Delphi 4 patch)

> TIA,

> Dave Prothero
> Director of R&D
> Argos Software

Hi Dave,

we had a simmilar problem. Delphi caused a GPF when we tried to INSERT an empty
memo field into a BLOB field (sub_type text) of an InterBase table.
Here's tha way we solved it:

    if NewFaAPForm.APInfoMemo.Text > '' then                            // memo
is not empty
        Params[0].asMemo := NewFaAPForm.APInfoMemo.Text    // insert text into
DB
    else begin
        Params[0].DataType :=
ftString;                                            // convert to other field
type

Params[0].Clear;
// empty value = insert no text in DB
    end;
    ExecSQL;

Other Threads