谢谢

解决方案 »

  1.   

    .....
    begin
       for i:=0 to ListBox1.Count-1 do
         begin
           if Self.ListBox1.selected[i] then
             str1:=self.ListBox1.Items[i];
         end;
    self.query1.close;
    self.query1.sql.clear;
    self.query1.sql.add('select * from 表名 where 字段名=:str');
    self.query1.ParamByName('str').AsString:=trim(str1);
    ....... 
    end;
      

  2.   

    var
      str1,str2 : string;
    begin
       for i:=0 to ListBox1.Count-1 do
         begin
           if Self.ListBox1.selected[i] then
             str1:=self.ListBox1.Items[i];
         end;
    self.query1.close;
    self.query1.sql.clear;
    str2 := 'select * from 表名 where 字段名=:str';
    self.query1.sql.add(str2);
    self.query1.ParamByName('str').AsString:=trim(str1);
    ....... 
    end;