Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


ID: 22674, The Power of Variants

by Mehmet Yüksek Email: Anonymous


Everybody mostly usage calculated fields, getting values from other tables or query, this example using Variants and return one or more columns only one command...
Download Details
FTP  download also available
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 6.0  to 6.0 1216 downloads
Copyright: No significant restrictions


Size: 697 bytes
Updated on Fri, 22 Oct 2004 00:12:07 GMT
Originally uploaded on Thu, 21 Oct 2004 01:20:17 GMT
SHA1 Hash: 43A0D88D21F2EB392697FC48B2D3607BB7E51827
MD5 Hash: 7983DEFEF962E08D9D17B5532B88CFBC

    Explore the files in this upload

Description
This is a Very Useful Function for applications,
(note: Im tested only on D6)

(Example-1)----------------------------------
procedure TfrmList.myQueryCalcFields(DataSet: TDataSet);
var
Res: Variant;
begin
Res := Dm1.GetValuesFromDB('SELECT LastName, FirstName FROM EMPLOYEE WHERE EmpNo='+myQueryEmpNo.asString,
['LastName','FirstName' {...} ]);

If not VarIsEmpty(Res) then //Check the Unassigned
begin
myQueryCalcLastNAME.Value := Res[0];
myQueryCalcFirstNAME.Value := Res[1];
{...}
end;

end;

(Example-2)----------------------------------
Res := GetValuesFromDB('SELECT a,b,c FROM TBL1 WHERE ROWID=1',['A','C']);

If not VarIsEmpty(Res) then
begin
ShowMessage('Result A:'+ Res[0] );
ShowMessage('Result C:'+ Res[1] );
end;

(Example-3)----------------------------------
Res := GetValuesFromDB('SELECT L.*, R.* FROM TABLE1 LEFT JOIN TABLE2 R ON (R.ID=L.ID) WHERE L.ID=100',['A','B','C','D','E']);

If not VarIsEmpty(Res) then
begin
Res[0] //--> Referenced to results of 'A' field
...
Res[4] //--> Referenced to results of 'E' field
end;
---------------------------------------
Sorry my bad English,
Good Bye...

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Server Response from: ETNACDC03