Syntax for retreiving data.
Syntax for retreiving data.
I've tried many options but still no success.
How do I do this ? Take the contents from a Table Field and put it in and edit box.
tEdit(fMemEdit.FindComponent('eMasterMemName').Name).text:= TStringField(FindComponent('DM.tbl.MasterMemName').Name).AsString;
(DM is data module)
Thanks Wallace
How do I do this ? Take the contents from a Table Field and put it in and edit box.
tEdit(fMemEdit.FindComponent('eMasterMemName').Name).text:= TStringField(FindComponent('DM.tbl.MasterMemName').Name).AsString;
(DM is data module)
Thanks Wallace
-
- Posts: 50
- Joined: Tue 25 Jan 2005 11:22
- Location: Somerville, MA
- Contact:
Re: Syntax for retreiving data.
You can't cast the name (a string) to a field. Something like
MemEdit.Text := MyTable.FieldByName( "FieldName" ).AsString;
MemEdit.Text := MyTable.FieldByName( "FieldName" ).AsString;
Re: Syntax for retreiving data.
Thanks for the reply. Almost there.
How do I achieve the following ?
table:='MyTable'
MemEdit.Text := table.FieldByName('FieldName').AsString;
I want to be able to dynamically retrieve data from a table.
How do I achieve the following ?
table:='MyTable'
MemEdit.Text := table.FieldByName('FieldName').AsString;
I want to be able to dynamically retrieve data from a table.
Re: Syntax for retreiving data.
This question concerns to principles of working with the TDataSet standard class. To resolve it, please refer to the Embarcadero documentation.
Re: Syntax for retreiving data.
I've tried various option and several Delphi local programmers but none seem to have a solution.
As this is a forum and not a support email, I hoping someone can shed some light on the matter.
Possibly I can use SQL statements to do the same thing?
I need to specify both the table and the field names in strings to retrieve the data..
As this is a forum and not a support email, I hoping someone can shed some light on the matter.
Possibly I can use SQL statements to do the same thing?
I need to specify both the table and the field names in strings to retrieve the data..
Re: Syntax for retreiving data.
You can implement the needed functionality using the following code.
var
MyTable: TMyTable;
...
MyTable.TableName := 'TableName';
MyTable.Open;
MemEdit.Text := MyTable.FieldByName('FieldName').AsString;
var
MyTable: TMyTable;
...
MyTable.TableName := 'TableName';
MyTable.Open;
MemEdit.Text := MyTable.FieldByName('FieldName').AsString;
Re: Syntax for retreiving data.
Something is not right. I get access violation error when I run this on the line eMasterMEMNAME.Text
If I comment out
tblName.TableName:='tblMaster' I don't have an error.
Really confused now.
If I comment out
tblName.TableName:='tblMaster' I don't have an error.
Code: Select all
var
tblName: TMyTable;
begin
tblName.TableName:='tblMaster';
eMasterMEMNAME.Text:='Test';
-
- Posts: 50
- Joined: Tue 25 Jan 2005 11:22
- Location: Somerville, MA
- Contact:
Re: Syntax for retreiving data.
You have to create the table object. Really, we can't help you unless you post your code. This is really a Delphi question, so you should post in the Embarcadero forums.
Re: Syntax for retreiving data.
Before using an object, you should create it first. To solve the issue, please add the following code line:
before the line:
Code: Select all
tblName := TMyTable.Сreate(nil);
Code: Select all
tblName.TableName:='tblMaster';