Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Query

Status
Not open for further replies.

sytech

Technical User
Oct 27, 2003
14
GB
Hi Guys

Am I missing something here I tried a query code from FAQ but I cannot get it to work the problem at present is when it gets to Parambyname it says missing operator or semicolon anybody with any ideas please.

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('Jobno,Customer,ref,notes');
datamodule2.JobStatus.sql.add('from Jobstable 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 may have missed something in your code, but there seems to be no keyword SELECT in the sql statement. Anyway, a good way to debug a select statement would be to get the program to show you the select statement before executing.

So maybe put some code in the program such as..

Inputbox('Some title','Some prompt',datamodule2.JobStatus.sql.text);

You can then copy the formatted sql string to the clipboard (and later into notepad or the Interbase SQL console to look at it more closely.)

Opp.
 
Hi Opp

Thanks for reply, yes I had missed the "Select" keyword in the SQL statement but it hasn't solved the problem, when it gets to the first parambyname it says "missing Operator or semicolon".

The inputbox you mention I am not sure what you mean as I am fairly new to delphi, do I just add the code as written at some point in the program.

Graham
 
I have just noticed in the help file that a TADOQuery cant be used like this.

Graham
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top