Solved

IndexFieldNames in my own component

Posted on 1998-02-07
5
223 Views
Last Modified: 2012-05-04
Hi

I am using D1 with Windows 3.11

I am creating a data aware component, and I need to add the property IndexFieldNames.  I know that the TTable to which it will be attached has this property, but my component needs to have two different indexes.  I have assumed that the TFieldDataLink has a relevant property, but I cannot find any help on it.

How do I add the property to my component so that it behaves the same way as it does in the TTable component?

Any help most appreciated.
0
Comment
Question by:jdthedj
  • 3
  • 2
5 Comments
 
LVL 8

Expert Comment

by:ZifNab
ID: 1358571
What about this?

(fDataLink.DataSource.DataSet as ttable).IndexFieldNames

Never tried out, but maybe...

Regards,Zif.

0
 
LVL 3

Author Comment

by:jdthedj
ID: 1358572
Hi ZifNab - thanks for replying

I tried that first, and it works OK at runtime, but I can't get it to work in Design mode - it tells me that the Dataset is not available.  I think that has something to do with the order in which things are initialised within the Component, but I don't know how to force different bits to initialise before others.

0
 
LVL 8

Accepted Solution

by:
ZifNab earned 100 total points
ID: 1358573
Hi jdthedj,
I guess I got it, pffff. found something in the help-file. It's made it in D2, so I don't know if it works under D1. But let me know!!

Put a table, datasource and button on the form, copy then this source. Linke table & datasource, etc...

Code can look some messy, sorry.  
unit unit1;

                      interface

                      uses
                        Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
                        StdCtrls, DB, Grids, DBGrids, DBTables,
                        dbitypes;

                      type
                        TForm1 = class(TForm)
                          Table1: TTable;
                                          DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    Button2: TButton;

    procedure Button2Click(Sender: TObject);
                        private
                          { Private declarations }
                        public
                          { Public declarations }
                        end;

                      var
                        Form1: TForm1;


                      implementation

                      {$R *.DFM}

                      uses dbiprocs;

                      procedure TForm1.Button2Click(Sender: TObject);
procedure ShowIndexDescs(ds: TDataSet);
const
  IDXStr = '%sIndex name: %s. Number of fields in key: %d'#13#10;
var
  CurProp: CURProps;
  pIndexDesc, pTmpMem: pIdxDesc;
  i, MemSize: integer;
  ShowString, IDXName: string;
begin
  Check(DbiGetCursorProps(ds.Handle, CurProp));
  MemSize := CurProp.iIndexes * sizeof(IDXDesc);
  pIndexDesc := AllocMem(MemSize);
  try
    pTmpMem := pIndexDesc;
    Check(DbiGetIndexDescs(ds.Handle, pIndexDesc));
    i := 0;
    ShowString := '';

    while (i < curProp.iIndexes) do begin
      with pTmpMem^ do begin
        // primary index does not have a name for PARADOX tables }
        if bPrimary and (StrComp(curProp.szTableType, szParadox) = 0) then
          IDXName := 'Primary'
        else
          IDXName := szName;
        ShowString := Format(IDXStr, [ShowString, IDXName, iFldsInKey])
      end;
      // increment pointer to the next record
      inc(pTmpMem);
      inc(i);
    end;
  finally

    FreeMem(pIndexDesc, MemSize);
    ShowMessage(ShowString);
  end;
end;

                      begin
                       ShowIndexDescs(DBGrid1.DataSource.DataSet);
                      end;

end.

for your component, use fdatalink.datasource.dataset instead of dbgrid.datasource.dataset
0
 
LVL 3

Author Comment

by:jdthedj
ID: 1358574
Hi Zif - we meet again.  The code didn't work quite as it was written, but it gave me a good start, and I have managed to do what I need to do.  Thanx
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1358575
Great! c.u. Zif.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

809 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