hericong(ifly) 的方法比较好 update tablename set 某字段="AAA" where 编号=A or 编号=B or.....where 编号 in (listbox1.items.(listbox1.intemindex),listbo2.items.(listbox2.intemindex,...))
var wherestr:string begin wherestr:='编号 in '+listbox1.items.(listbox1.intemindex),listbox2.items.(listbox2.intemindex,...)) end;
procedure TForm1.Button1Click(Sender: TObject); begin if ListBox1.Items.Count > 0 then ADOQuery.SQL.Text := Format('update tablename set 某字段="AAA" where 编号 IN (''%s'')', [StringReplace(Trim(ListBox1.Items.Text), #13#10, ''',''', [rfReplaceAll])]); end;
var wherestr:string begin wherestr:='编号 in '+listbox1.items.(listbox1.itemindex),listbox2.items.(listbox2.itemindex,...)) end; 是itemindex
嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻 嘻嘻嘻请试试嘻嘻嘻嘻 嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻procedure TForm1.Button1Click(Sender: TObject); begin if ListBox1.Items.Count > 0 then ADOQuery.SQL.Text := Format('update tablename set 某字段="AAA" where 编号 IN (''%s'')', [StringReplace(Trim(ListBox1.Items.Text), #13#10, ''',''', [rfReplaceAll])]); end;
var i:integer; str:string; begin str:=''; for i:=0 to listbox1.Items.Count-1 do begin if i=listbox1.Items.Count-1 then str:=str+'编号='+''''+listbox1.Items[i]+'''' else str:=str+'编号='+ '''' + listbox1.Items[i]+ '''' + ' or '; end; showmessage(str); end;
update tablename set 某字段="AAA" where 编号=A or 编号=B or.....where 编号 in (listbox1.items.(listbox1.intemindex),listbo2.items.(listbox2.intemindex,...))
wherestr:string
begin
wherestr:='编号 in '+listbox1.items.(listbox1.intemindex),listbox2.items.(listbox2.intemindex,...))
end;
begin
if ListBox1.Items.Count > 0 then
ADOQuery.SQL.Text := Format('update tablename set 某字段="AAA" where 编号 IN (''%s'')',
[StringReplace(Trim(ListBox1.Items.Text), #13#10, ''',''', [rfReplaceAll])]);
end;
wherestr:string
begin
wherestr:='编号 in '+listbox1.items.(listbox1.itemindex),listbox2.items.(listbox2.itemindex,...))
end;
是itemindex
嘻嘻嘻请试试嘻嘻嘻嘻
嘻嘻嘻嘻嘻嘻嘻嘻嘻嘻procedure TForm1.Button1Click(Sender: TObject);
begin
if ListBox1.Items.Count > 0 then
ADOQuery.SQL.Text := Format('update tablename set 某字段="AAA" where 编号 IN (''%s'')',
[StringReplace(Trim(ListBox1.Items.Text), #13#10, ''',''', [rfReplaceAll])]);
end;
begin
str:='';
for i:=0 to listbox1.Items.Count-1 do
begin
if i=listbox1.Items.Count-1 then
str:=str+'编号='+''''+listbox1.Items[i]+''''
else
str:=str+'编号='+ '''' + listbox1.Items[i]+ '''' + ' or ';
end;
showmessage(str);
end;