Using database entries as function parameters

362 Views Asked by At

I am using Delphi to access my pgsql database using the components:

ADOQuery, ADOConnection and DataSource and DBGrid.

I 've seen that it is convenient to present data in a TStringGrid (rather than a DBGrid)so am also using the code below:

procedure TForm2.StringGrid1Click(Sender: TObject);
var
  x,y: integer;
begin
  StringGrid1.ColCount := DBGrid1.Columns.Count;
  StringGrid1.RowCount := DBGrid1.DataSource.DataSet.RecordCount+1;
  StringGrid1.FixedCols := 0;
  for y := 0 to DBGrid1.Columns.Count-1 do
    StringGrid1.Cells[y, 0] := DBGrid1.Columns[y].Title.Caption;
  x := 1;
  DBGrid1.DataSource.DataSet.DisableControls;
  DBGrid1.DataSource.DataSet.First;

  while not DBGrid1.DataSource.DataSet.Eof do
  begin
    for y := 0 to DBGrid1.Columns.Count-1 do
      StringGrid1.Cells[y,x] :=                                
        DBGrid1.DataSource.DataSet.FieldByName(DBGrid1.Columns[y].FieldName).AsString;
    inc(x);
    DBGrid1.DataSource.DataSet.Next;
  end;
  DBGrid1.DataSource.DataSet.EnableControls;
end;   

The database has 2 columns of G and T data respectively. Now, in a different project, I have made a number of functions setting G,T parametres as indicated below:

 function FindSomething(G, T:double):double;

What I am asking is how can I use as G, T parametres, for my function, the cell entries from the above database columns? I am very new at this and it's been very tricky all the way. Any help very much appreciated.

0

There are 0 best solutions below