Hi Folks
I need a query to return data from jobtable I have tried code below from FAQ area but then found out that ParamByName doesnt work with ADOquery How do I change this to Parameters or is there an easier way I have tried filering with pos but its case sensitive so I dont get all the data I cant change the underlying MS Access tables because their distributed.
Any Ideas Would be greatly appreciated.
procedure TJobStatus.FormCreate(Sender: TObject);
begin
inherited;
SString:='%%';
cbselect.ItemIndex :=0;
end;
procedure TJobStatus.edtselectChange(Sender: TObject);
begin
inherited;
sstring :='%' + edtselect.text + '%';
end;
procedure TJobStatus.bbtnselectClick(Sender: TObject);
begin
inherited;
with jobstatus do
begin
close;
datamodule2.JobStatus.SQL.clear;
datamodule2.JobStatus.sql.add('SELECT Jobno,Customer,ref, notes');
datamodule2.JobStatus.sql.add('from Jobstable');
case cbselect.ItemIndex of
0: begin
datamodule2.JobStatus.sql.add ('where jobno like :searchstring');
Parambyname('searchstring').asstring:=sstring;
end;
1: begin
datamodule2.JobStatus.sql.add ('where Customer like :searchstring');
Parambyname('searchstring').asstring:=sstring;
end;
2: begin
datamodule2.JobStatus.sql.add ('where Ref like :searchstring');
Parambyname('searchstring').asstring:=sstring;
end;
3: begin
datamodule2.JobStatus.sql.add ('where notes like :searchstring');
Parambyname('searchstring').asstring:=sstring;
end;
end;
Graham
I need a query to return data from jobtable I have tried code below from FAQ area but then found out that ParamByName doesnt work with ADOquery How do I change this to Parameters or is there an easier way I have tried filering with pos but its case sensitive so I dont get all the data I cant change the underlying MS Access tables because their distributed.
Any Ideas Would be greatly appreciated.
procedure TJobStatus.FormCreate(Sender: TObject);
begin
inherited;
SString:='%%';
cbselect.ItemIndex :=0;
end;
procedure TJobStatus.edtselectChange(Sender: TObject);
begin
inherited;
sstring :='%' + edtselect.text + '%';
end;
procedure TJobStatus.bbtnselectClick(Sender: TObject);
begin
inherited;
with jobstatus do
begin
close;
datamodule2.JobStatus.SQL.clear;
datamodule2.JobStatus.sql.add('SELECT Jobno,Customer,ref, notes');
datamodule2.JobStatus.sql.add('from Jobstable');
case cbselect.ItemIndex of
0: begin
datamodule2.JobStatus.sql.add ('where jobno like :searchstring');
Parambyname('searchstring').asstring:=sstring;
end;
1: begin
datamodule2.JobStatus.sql.add ('where Customer like :searchstring');
Parambyname('searchstring').asstring:=sstring;
end;
2: begin
datamodule2.JobStatus.sql.add ('where Ref like :searchstring');
Parambyname('searchstring').asstring:=sstring;
end;
3: begin
datamodule2.JobStatus.sql.add ('where notes like :searchstring');
Parambyname('searchstring').asstring:=sstring;
end;
end;
Graham