أظن أنني لم أستطع توضيح مشكلتي جيدا لذا ارفقت السورس كوند لكي يتسنى لكم إلقاء نظرة عليه …
هذا هو السورس كود
اليونيت الاولى ..
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Menus, ComCtrls, Grids, DBGrids, DB, ADODB,
DBCtrls, Buttons, Vcl.Mask, tlhelp32;
type
TForm1 = class(TForm)
ADOConnection1: TADOConnection;
ADOTable1: TADOTable;
DataSource1: TDataSource;
DBGrid1: TDBGrid;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
label1: TLabel;
label3: TLabel;
label2: TLabel;
DBNavigator1: TDBNavigator;
button2: TBitBtn;
button1: TBitBtn;
procedure button1Click(Sender: TObject);
procedure button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.button1Click(Sender: TObject);
var x: MyThread;
begin
x := MyThread.Create(false);
end;
procedure TForm1.button2Click(Sender: TObject);
var x: MyThread;
begin
x.terminate
end;
end;
end.
اليونيت الثانية ..
unit Unit2;
interface
uses
System.Classes, Unit1;
type
MyThread = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
end;
implementation
procedure MyThread.Execute;
begin
if Form1.Edit1.Text > '' then
begin
Form1.ADOTable1.Locate('Field1', Form1.Edit1.Text, [loPartialKey]);
Form1.Label1.Caption := Form1.ADOTable1.FieldByName('Field2').Value;
Form1.Label2.Caption := Form1.ADOTable1.FieldByName('Field3').Value;
Form1.Label3.Caption := Form1.ADOTable1.FieldByName('Field1').Value;
end;
if Form1.Edit2.Text > '' then
begin
Form1.ADOTable1.Locate('Field2', Form1.Edit2.Text, [loPartialKey]);
Form1.Label1.Caption := Form1.ADOTable1.FieldByName('Field2').Value;
Form1.Label2.Caption := Form1.ADOTable1.FieldByName('Field3').Value;
Form1.Label3.Caption := Form1.ADOTable1.FieldByName('Field1').Value;
end;
if Form1.Edit3.Text > '' then
begin
Form1.ADOTable1.Locate('Field3', Form1.Edit3.Text, [loPartialKey]);
Form1.Label1.Caption := Form1.ADOTable1.FieldByName('Field2').Value;
Form1.Label2.Caption := Form1.ADOTable1.FieldByName('Field3').Value;
Form1.Label3.Caption := Form1.ADOTable1.FieldByName('Field1').Value;
end ;
end;
end.
وشكرا لكم