数据库更新语句 急
数据库更新语句求助 急!!在线等!!!
var
Count:integer;
begin
adoquery3.close;
adoquery3.SQL.Clear;
adoquery3.sql.Add( 'select 现存量 from 图书信息 where 图书编号= ' ' '+edit5.text+ ' ' ' ');
adoquery3.open;
Count:=adoquery3.fieldbyname( '现存量 ').AsInteger;
Count:= Count-1;
if Count <> 0 then
begin
adoquery3.close;
adoquery3.SQL.Clear;
adoquery3.sql.add( 'update 图书信息 set 现存量 = ' ' '+inttostr(Count)+ ' ' ' where 图书编号= ' ' '+edit5.text+ ' ' ' ');
adoquery3.open;
end;
end.
end;
执行的时候报错“当前提供程序不支持从单一执行返回多个纪录集”
麻烦各位帮帮忙,很急
------解决方案--------------------
adoquery3.open;
改为adoquery3.execsql;
updata 没有结果集返回
------解决方案--------------------
你上面的意思好象是要库存减一对不对?
直接这样就行啦:
adoquery3.close;
adoquery3.SQL.Clear;
adoquery3.sql.add( 'update 图书信息 set 现存量 =现存量-1 where 图书编号= ' ' '+edit5.text+ ' ' ' ');
adoquery3.execsql;
var
Count:integer;
begin
adoquery3.close;
adoquery3.SQL.Clear;
adoquery3.sql.Add( 'select 现存量 from 图书信息 where 图书编号= ' ' '+edit5.text+ ' ' ' ');
adoquery3.open;
Count:=adoquery3.fieldbyname( '现存量 ').AsInteger;
Count:= Count-1;
if Count <> 0 then
begin
adoquery3.close;
adoquery3.SQL.Clear;
adoquery3.sql.add( 'update 图书信息 set 现存量 = ' ' '+inttostr(Count)+ ' ' ' where 图书编号= ' ' '+edit5.text+ ' ' ' ');
adoquery3.open;
end;
end.
end;
执行的时候报错“当前提供程序不支持从单一执行返回多个纪录集”
麻烦各位帮帮忙,很急
------解决方案--------------------
adoquery3.open;
改为adoquery3.execsql;
updata 没有结果集返回
------解决方案--------------------
你上面的意思好象是要库存减一对不对?
直接这样就行啦:
adoquery3.close;
adoquery3.SQL.Clear;
adoquery3.sql.add( 'update 图书信息 set 现存量 =现存量-1 where 图书编号= ' ' '+edit5.text+ ' ' ' ');
adoquery3.execsql;