Mirror

How to insert data in Paradox memo fields using SQL INSERT statements (Views: 101)


Problem/Question/Abstract:

How to insert data in Paradox memo fields using SQL INSERT statements

Answer:

Assuming you are using at least Delphi 3, you need to represent the memo field in the SQL statement with a parameter.

INSERT INTO YourTable
(StrField, MemoField)
VALUES("AAA", : MemoParam)

The parameter would need to be the appropriate data type: the TParam.DataType property would need to be ftMemo. Then, before executing the SQL statement, provide the parameter with a value. How you provide the parameter value will vary depending on the form the source data is in.

If the source is a file, use the TParam.LoadFromFile method.

Query1.ParamByName('MemoParam').LoadFromFile('c:\windows\network.txt');

If the source is a PChar (or equivalent) buffer, use direct assignment of the value to the parameter with the TParam.AsMemo property.

Query1.ParamByName('MemoParam').AsMemo := Buffer;

If the source is in the form of a memory stream, use the TParam.LoadFromStream method.

Query1.ParamByName('MemoParam').LoadFromStream(YourMemoryStream);

<< Back to main page