Solved

IndexFieldNames in my own component

Posted on 1998-02-07
5
224 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Magic Software info 18 139
Convert GUI app into console app for Win32 Env 5 110
How to debug For loops? 3 57
SUM 2 INTEGER ARRAYS INTO 1 10 108
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

820 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