各位大虾请关注 procedure TForm6.BitBtn_rightClick(Sender: TObject); var I:integer; str:string; begin for i := 0 to (ListBox_left.Items.Count - 1) do begin if ListBox_left.Selected[i] then begin str:=listbox_left.items[i]; listbox_right.Items.add(listbox_left.items[i]); listbox_left.Items.Delete(listbox_left.ItemIndex); end; end; with query4 do begin close; sql.clear; sql.add('update userguanli_3 set flag=1 where butn=:str'); execsql; end; end;
sql 语句报错execsql;
sql.add('update userguanli_3 set flag=1 where butn=:str'); 这一句语法有问题如果str是参数的话,你要 query4.Parameters.ParamByName('str').Value:=str;或 sql.add('update userguanli_3 set flag=1 where butn='+str);
procedure TForm6.BitBtn_rightClick(Sender: TObject);
var I:integer;
str:string;
begin
for i := 0 to (ListBox_left.Items.Count - 1) do
begin
if ListBox_left.Selected[i] then
begin
str:=listbox_left.items[i]; listbox_right.Items.add(listbox_left.items[i]);
listbox_left.Items.Delete(listbox_left.ItemIndex);
end;
end;
with query4 do
begin
close;
sql.clear;
sql.add('update userguanli_3 set flag=1 where butn=:str');
execsql;
end;
end;
这一句语法有问题如果str是参数的话,你要
query4.Parameters.ParamByName('str').Value:=str;或
sql.add('update userguanli_3 set flag=1 where butn='+str);
15个了,当它访问第16个的时候,就会出错!