数据库中学生表有一列为sbnum,默认值为5,
在下面过程中。我想下上,if sbnum>0;条件。
不知道怎么加,各位帮帮忙。
procedure Tadmin_user.Button2Click(Sender: TObject);
var Bno1:string;
begin
Sno:=trim(edit1.Text);
Bno1:=trim(combobox1.Text);
if (Bno1<>'') then adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('update student set sbnum=sbnum-1 where sno='+sno+';');
showmessage(adoquery1.SQL.Text);
adoquery1.Open;
end;
在下面过程中。我想下上,if sbnum>0;条件。
不知道怎么加,各位帮帮忙。
procedure Tadmin_user.Button2Click(Sender: TObject);
var Bno1:string;
begin
Sno:=trim(edit1.Text);
Bno1:=trim(combobox1.Text);
if (Bno1<>'') then adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('update student set sbnum=sbnum-1 where sno='+sno+';');
showmessage(adoquery1.SQL.Text);
adoquery1.Open;
end;
var Bno1:string;
begin
Sno:=trim(edit1.Text);
Bno1:=trim(combobox1.Text);
if (Bno1 <>'') then adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('update student set sbnum=sbnum-1 where sno>'+sno);
showmessage(adoquery1.SQL.Text);
adoquery1.Open;
end;
var Bno1:string;
begin
Sno:=trim(edit1.Text);
Bno1:=trim(combobox1.Text);
if (Bno1 <>'') then
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('update student set sbnum=sbnum-1 where sno=:sno;);
adoquery1.Parameters.ParamByName('sno').value:=Sno;
adoquery1.ExecSQL; //update的SQL语句,应该用adoQuery1.ExecSQL
end;
end;
var Bno1:string;
begin
Sno:=trim(edit1.Text);
Bno1:=trim(combobox1.Text);
if (Bno1 <>'') then
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('update student set sbnum=sbnum-1 where sno=:sno');
adoquery1.Parameters.ParamByName('sno').value:=Sno;
adoquery1.ExecSQL; //update的SQL语句,应该用adoQuery1.ExecSQL
end;
end;
procedure Tadmin_user.Button2Click(Sender: TObject);
var Bno1:string;
begin
Sno:=trim(edit1.Text);
Bno1:=trim(combobox1.Text);
if (Bno1 <>'') then adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('update student set sbnum=sbnum-1 where sbnum>0 and sno='+sno+';');
showmessage(adoquery1.SQL.Text);
adoquery1.Open;
end;
procedure Tadmin_user.Button2Click(Sender: TObject);
var Bno1:string;
begin
Sno:=trim(edit1.Text);
Bno1:=trim(combobox1.Text);
if (Bno1 <>'') then
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('update student set sbnum=sbnum-1 where sno=:sno');
adoquery1.Parameters.ParamByName('sno').value:=Sno;
adoquery1.ExecSQL; //update的SQL语句,应该用adoQuery1.ExecSQL
end;
end;
var Bno1:string;
begin
Sno:=trim(edit1.Text);
Bno1:=trim(combobox1.Text);
if (Bno1 <>'') then
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('update student set sbnum=sbnum-1 where sno=:sno');
adoquery1.Parameters.ParamByName('sno').value:=Sno;
adoquery1.ExecSQL; //update的SQL语句,应该用adoQuery1.ExecSQL
end;
end;
var Bno1:string;
begin
Sno:=trim(edit1.Text);
Bno1:=trim(combobox1.Text);
if (Bno1 <>'') then
begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('update student set sbnum=sbnum-1 where sno=:sno and sbnum>0');
adoquery1.Parameters.ParamByName('sno').value:=Sno;
adoquery1.ExecSQL; //update的SQL语句,应该用adoQuery1.ExecSQL
end;
end;
procedure Tadmin_user.Button2Click(Sender: TObject);
var Bno1:string;
begin
Sno:=trim(edit1.Text);
Bno1:=trim(combobox1.Text);
if (Bno1 <>'') then begin
with adoquery1 do begin
Close;
SQL.Clear;
SQL.Add('update student set sbnum=sbnum-1 where sno=:sno and sbnum>0');
parameters.parambyname('sno').value :=sno;
ExecSQL;
end;
end;
end;