Board index » delphi » Filling an array with query result data

Filling an array with query result data

I may be missing something simple (fairly new to Delphi), but I do not know how
to perform an SQL query and have the result displayed either in a StringGrid
component (not a DBStringGrid) or assigned to the elements of an array.

I can easilly have the data displayed in a StringGrid if I use a Table
component as opposed to a Query component, but I need the flexibility of an SQL
query.  What I am endeavouring to do is to have the fixed columns of the
StringGrid display data from one table, the fixed row(s) with calculated data
(day & dates), and the remaining StringGrid cells filled with values (if they
exist) from up to three other tables.  Some cells may remain empty if there are
no values to be assigned to that particular co-ordinate (i.e. no task for a
particular person on a given date).

The form I am working on is to be a worksheet for a roster program which I hope
will include some rule based processing.  Any thoughts would be appreciated.

 

Re:Filling an array with query result data


I am not sure I understand the problem.  Assigning the value from a field to
a cell in a string grid is exactly the same with a TQuery as it is with a
TTable.  The same is true of assigning elements to an array.  Can you be
more explicit about what you are trying to do and what code does not work.

var
  V:   array[0..20] of Variant;
begin
  V[1] := Query1.FieldByName('SomeField').AsString;

--
Bill

(TeamB cannot answer questions received via email.)
(To contact me for any other reason remove nospam from my address)

Other Threads