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

Posted on 2009-04-19
Last Modified: 2013-11-23
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
Question by:TTRMW
    1 Comment
    LVL 13

    Accepted 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

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
    SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now