Hi, I am migrating a Delphi 5 application to Delphi XE.
I also migrate the Dbase data to MySql.
I have a MyDac 6 Pro licence.
To make the migration smoother, I want to add a method to MyTable to simulate a seek. I have try with the Delphi class explorer but without succes.
How could I do that ?
What do I need to do that ?
Thanks
Yves.
MyTable adding a method
-
AndreyZ
Hello,
You can inherit your own table class from the TMyTable class and add a new method in the following way:
You can inherit your own table class from the TMyTable class and add a new method in the following way:
Code: Select all
TNewMyTable = class(TMyTable)
public
procedure NewMethod;
end;
procedure TNewMyTable.NewMethod;
begin
//your code
end;Ok
Hi, I understand what you do, no problem.
When I drop the component TMyTable in a unit, it create an instance of TMyTable not from the new Class I just create as in your example.
So the compiler complain.
[DCC Erreur] SDIMAIN.PAS(56): E2003 Identificateur non déclaré : 'seek'
I have try this other way to do what I want and it seem to work well.
This is just a fast testing but it work.
Thanks
When I drop the component TMyTable in a unit, it create an instance of TMyTable not from the new Class I just create as in your example.
So the compiler complain.
[DCC Erreur] SDIMAIN.PAS(56): E2003 Identificateur non déclaré : 'seek'
I have try this other way to do what I want and it seem to work well.
This is just a fast testing but it work.
Thanks
Code: Select all
unit SDIMAIN;
interface
uses Windows, Classes, Graphics, Forms, Controls, Menus,
Dialogs, StdCtrls, Buttons, ExtCtrls, ComCtrls, ImgList, StdActns,
ActnList, ToolWin, Grids, DBGrids, CRGrid, DB, DBAccess, MyAccess, MemDS;
type
TSDIAppForm = class(TForm)
MyConnection1: TMyConnection;
MyDataSource1: TMyDataSource;
CRDBGrid1: TCRDBGrid;
Label1: TLabel;
Label2: TLabel;
MyTable1: TMyTable;
procedure FileExit1Execute(Sender: TObject);
procedure Label2Click(Sender: TObject);
private
{ Déclarations privées }
public
{ Déclarations publiques }
end;
TMyyTable = class helper for TMyTable
//TMyyTable = class(TMyTable)
public
function Seek(LeFiltre: String): Boolean;
end;
var
SDIAppForm: TSDIAppForm;
implementation
uses about;
{$R *.dfm}
function TMyyTable.Seek(LeFiltre: String): Boolean;
begin
Self.FilterSQL := LeFiltre;
if Self.RecordCount = 0 then
Result := false
else
Result := True;
end;
procedure TSDIAppForm.FileExit1Execute(Sender: TObject);
begin
Close;
end;
procedure TSDIAppForm.Label2Click(Sender: TObject);
begin
MyTable1.seek('Perma = 1017274');
end;
end.