Forum > Databases

TDBMemo-Error

(1/1)

Knoppers:
Hi there,

I use the SQLdb-Package to Access and the DataAccess components to display/edit data from a firebird 1.5 database.
TDBLabel and TDBEdit are working well. TDBCheckBox does not really, but okay.

So far so good.

Then I places a TDBMemo on my form to access a text-blob field. It diplays the content but if I post any changes of this field my app raise an excpetion: "Acces violation". If I press ignore, the app is standing still/hang off.
The debugger opens the file streams.inc which and marks the


--- Code: ---
  procedure TStream.WriteBuffer(const Buffer; Count: Longint);

    begin
       if Write(Buffer,Count)<Count then
         Raise EWriteError.Create(SWriteError);
    end;

--- End code ---


at the if clause.

Can anyone help my solve this problem or how to edit blob-fields on a other way?

Thx[/code]

JanH:
Hi again,

I've found a way to bypass the problem with TDBMemo. I think cause of the problem is an incorrect blob-field handling.
So I decide to change the data field to VARCHAR and make it editable in the TMemo component. The todos the make it:

- catch AfterScroll of TDataSet event to get the content of the field
- catch BeforePost of TDataSet event to set the content of the field
- catch OnChange event of Memo to automatically change the state of TDataSet to dsEdit


--- Code: ---
procedure TForm1.SQLQuery1AfterScroll(DataSet: TDataSet);
begin
  Memo1.Tag := 1;
  Memo1.Lines.Text := SQLQuery1.FieldByName( <Field> ).AsString;
  Memo1.Tag := 0;
end;

procedure TForm1.SQLQuery1BeforePost(DataSet: TDataSet);
begin
  SQLQuery1.FieldByName( <Field> ).Value := Memo1.Lines.Text;
end;

procedure TForm1.Memo1Change(Sender: TObject);
begin
  if( Memo1.Tag=0 )then
    if( SQLQuery1.State=dsBrowse )then
      SQLQuery1.Edit;
end;

--- End code ---


Make sure the Memo.Tag is not used otherwise. The switch of the tag value indicates if the dsEdit-Mode to be set when memo text is changing.

Greets

Navigation

[0] Message Index

Go to full version