Re: Function to return dataset record



Sorry, wrong post. It should be on language newsgroup.

"Benson Wong" <benson@xxxxxxxxxxxxxxxxxxxxx> ׫??ì¶à]¼þÐÂÂ?
:4483f57a@xxxxxxxxxxxxxxxxxxxxxxxxx
I know how to write simple function to return string, integer, boolean
type.

But how to write a function to return a control, eg. TTable?
My problem is:
- Given a tablename, a key field and its value
- select data from the database
- return the Dataset records (which may be more than 1)
- Something like this:
function ReturnDatasetRecord(Tablename, KeyFieldName, KeyFieldValue):
TDataset
begin
s:='select * from '+Tablename+' where
'+KeyFieldName+'='+quotedstr(KeyFieldValue);
try
Query:=TQuery.create(nil);
Query.sql.text:=s;
Query.open;
result:=Query; //????????????
finally
Freeandnil(Query);
end;




.



Relevant Pages

  • Re: Function to return dataset record
    ... function GetCorrectNewsGroup(topic: string): string; ... But how to write a function to return a control, ... function ReturnDatasetRecord(Tablename, KeyFieldName, KeyFieldValue): ... TDataset ...
    (borland.public.delphi.non-technical)
  • Function to return dataset record
    ... I know how to write simple function to return string, integer, boolean type. ... But how to write a function to return a control, ... function ReturnDatasetRecord(Tablename, KeyFieldName, KeyFieldValue): ...
    (borland.public.delphi.non-technical)