procedure TForm3.Button3Click(Sender: TObject); 
var i,j:integer; 

var str1,str2,str3:string; 
begin 
with adoquery1 do 
begin 
close; 
sql.Clear; 
  if combobox5.Text='' then 
    str1:='' 
  else 
    str1:=' and new_blade_type='''+combobox5.Text+''''; 
  if combobox7.Text='' then 
    str2:='' 
  else 
    str2:=' and team='''+combobox7.Text+''''; 
  if Edit9.Text='' then 
    str3:='' 
  else 
    str3:=' and operator='''+Edit9.Text+''''; 
  Sql.Text:='select * from blade where 1=1'+str1+str2+str3; 
open; 
First; 

stringgrid1.RowCount:=RecordCount; 
stringgrid1.ColCount:=Fields.Count; 


  for i:=1 to stringgrid1.RowCount-1 do 
  begin 
    for j:=1 to stringgrid1.ColCount-1 do 
        stringgrid1.Cells[j,i]:=Fields[j].Value; 
    Next; 
    end; 
end; 
ADOQUERY1.close; 
end;

//This code work without any errors but show nothing when click the button3.

BTW
I am really a ROOKIE ,If I violate anything ,just give me a feedback. thanks a lot.

Hi,

1.Did you execute your sql query in an Query Analyzer?(I assume that you use MSSQL Server). Get your runtime query with the Profiler and run it. Maybe is nothing to display.
2.Why don't you use a db aware component - DBGrid? You will work directly on the dataset and actions (update, insert, delete) will be easier to do.

3. If your query returns data from server, try the following code to populate your StringGrid:

i := 0;
while not Eof do 
begin     
      for j:=0 to stringgrid1.ColCount-1 do  //or to FieldCount - 1       
              stringgrid1.Cells[j,i]:=Fields[j].asString;     
       Next;     
      inc(i); 
end;
This article has been dead for over six months. Start a new discussion instead.