• 0

[Delphi] Posting MemoField To Database


Question

6 answers to this question

Recommended Posts

  • 0

Long time since I used Delphi, but try this.

First, set DBMemo Datasource and Datafield properties.

Add this code to where you post the data, like button's OnClick event.

// Insert to insert new record and Edit to edit current record.
// Let's insert new record for now.
DBMemo1.DataSource.DataSet.Insert;
DBMemo1.DataSource.DataSet.FieldByName(DBMemo1.DataField).AsString := DBMemo1.Text;
DBMemo1.DataSource.DataSet.Post;

  • 0
  Wilhelmus said:

Long time since I used Delphi, but try this.

First, set DBMemo Datasource and Datafield properties.

Add this code to where you post the data, like button's OnClick event.

// Insert to insert new record and Edit to edit current record.
// Let's insert new record for now.
DBMemo1.DataSource.DataSet.Insert;
DBMemo1.DataSource.DataSet.FieldByName(DBMemo1.DataField).AsString := DBMemo1.Text;
DBMemo1.DataSource.DataSet.Post;

Thanks for the help. Doesn't seem to work though, well what I have got is the following:

DataMod.dsTransactions.DataSet.FieldByName(DataMod.dsTransactions.DataSet.DataSetField.AsString) := Receipt.Text;

I can a left cannot be assigned to error, btw I do have the edit etc. The above was done on using auto complete thinggy as the exact code doesn't match. Any ideas?

Also just noticed, I am not using a DBMemo field. I need to add stuff too it as I go along you see. If I was to use a DBMemo I would have to make loads of changes to me code.

  • 0

^

well that is poor programming on your behalf- you have tightly bound your code to the

Either way I would move to dbmemo, it makes life simple.

change

DataMod.dsTransactions.DataSet.FieldByName(DataMod.dsTransactions.DataSet.DataSetField.AsString) := Receipt.Text;

to

DataMod.dsTransactions.DataSet.FieldByName(DataMod.dsTransactions.DataSet.DataSetField.AsString).Value := Receipt.Text;

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.