?
Solved

IndexFieldNames in my own component

Posted on 1998-02-07
5
Medium Priority
?
236 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 300 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month8 days, 21 hours left to enroll

764 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