[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 277
  • Last Modified:

Looking to pass data from two columns of a table on an access database into a delphi array...?

Hi there, looking to take the values in two fields from one record and put it into an array. Ie - user queries to find a certain record, then clicks to add the data from two columns into an array.

So it'll be on runtime, onclick event, the record will be selected using a DBGrid.

Cheers in advance
1 Solution
Ummm... what is the name of your dataset? What is the datatype of the two fields? Is the datatype of the 2 fields the same? e.g. are they both integers?
You could create a global array in your unit:
  myarray : array [0 .. 1] of string;
then let's say the onclick event is from a button
procedure TForm1.MyButtonClick(Sender: TObject);

  myarray[0] :=  DBGrid1.DataSource.DataSet.fieldbyname('Field1').AsString;
  myarray[1] :=  DBGrid1.DataSource.DataSet.fieldbyname('Field2').AsString;


Then later you can use it thus:
showmessage('The first value in the array is: ' + myarray[0])'
showmessage('The second value in the array is: ' + myarray[1])'
NOTE: I have not tested this code.

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now