Board index » delphi » Accessing Value From a SQL based DBGrid

Accessing Value From a SQL based DBGrid

I have a need to access and store a specific integer value from the
currently selected cell of a DBGrid.  The DBGrid is being supplied by a
TQuery component.  I also have a DBedit component (also tied to the same
SQL query) that displays the current cell value from the DBGrid.  I need
to store this value to a variable but am at a complete loss as to how
this can be done- or  if it can be done.  Any ideas/examples.
TIA
KCS
 

Re:Accessing Value From a SQL based DBGrid


KCS,

This should get you started......

function DBGrid_CurrVal(The_Grid : TDBGrid) : string
begin
   result := The_Grid.SelectedField.AsString;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  GridVal : string
begin
    GridVal := DBGrid_CurrVal(DBGrid1);
    ShowMessage(GridVal);
end;

On Wed, 16 Jun 1999 19:29:21 -0500, Ken Stupka <kstu...@swbell.net>
wrote:

Quote
>I have a need to access and store a specific integer value from the
>currently selected cell of a DBGrid.  The DBGrid is being supplied by a
>TQuery component.  I also have a DBedit component (also tied to the same
>SQL query) that displays the current cell value from the DBGrid.  I need
>to store this value to a variable but am at a complete loss as to how
>this can be done- or  if it can be done.  Any ideas/examples.
>TIA
>KCS

--Donovan

Donovan J. Edye
Namadgi Systems
Web: www.namsys.com.au
E-Mail: dono...@namsys.com.au
Voice: +61 2 6285-3460
Fax: +61 2 6285-3459
TVisualBasic := Class(None);

Re:Accessing Value From a SQL based DBGrid


Have you tried using persistent fields? You can declare them using the
fields editor on your TQuery by right-clicking or double-clicking on it.
Then right-click on the empty field editor and click Add fields on the popup
menu. You will be prompted to chose from the fields of tour TQuery. Click OK
and your automatically declared persistent field can be used as your
variable.

Note though that changes to its value will be reflected on your TQuery (if
updatable).

Edgar D, Jordan
sp...@k-net.edu

Quote
Ken Stupka wrote in message <37684161.489A8...@swbell.net>...
>I have a need to access and store a specific integer value from the
>currently selected cell of a DBGrid.  The DBGrid is being supplied by a
>TQuery component.  I also have a DBedit component (also tied to the same
>SQL query) that displays the current cell value from the DBGrid.  I need
>to store this value to a variable but am at a complete loss as to how
>this can be done- or  if it can be done.  Any ideas/examples.
>TIA
>KCS

Other Threads