I'm trying to pull off running a query multiple times and populating a single DBGRID. I would like the results to append to the bottom of the DBGRID but have landed flat on my face.
I'm assigning the variable 'item' with a differing value and looping back through a the query again but will no luck. There's probably some basic rule that I'm violating and if so please suggest an alternative.
This is pulling a number from a TstringList sending it through a query then pulling another number (repeat until End of stinglist count)
Here's the code sample:
var
stringlist:Tstringlist;
i:integer;
s,Item,sql:string;
Begin
Stringlist:=Tstringlist.create;
Stringlist.loadfromfile('...
...
...
for i:=0 to Stringlist.count-1 do
Begin
s:=stringlist;
item:=copy(S,1,6);
adoquery1.close;
adoquery1.sql.clear;
sql:='select description from items where itemnumber='+quotedstr(item)+'';
adoquery1.sql.add(SQL);
adoquery1.open;
End;
Stringlist.free
//I can populate the DBGRID with a single SQL query entered directly from the ADOQUERY1 property so my connections are good but my logic is probably twisted somewhere.
I've stepped traced through the code and it's properly getting a different value on each loop but ending with an empty DBGRID.
Is there an easier way?
I'm assigning the variable 'item' with a differing value and looping back through a the query again but will no luck. There's probably some basic rule that I'm violating and if so please suggest an alternative.
This is pulling a number from a TstringList sending it through a query then pulling another number (repeat until End of stinglist count)
Here's the code sample:
var
stringlist:Tstringlist;
i:integer;
s,Item,sql:string;
Begin
Stringlist:=Tstringlist.create;
Stringlist.loadfromfile('...
...
...
for i:=0 to Stringlist.count-1 do
Begin
s:=stringlist;
item:=copy(S,1,6);
adoquery1.close;
adoquery1.sql.clear;
sql:='select description from items where itemnumber='+quotedstr(item)+'';
adoquery1.sql.add(SQL);
adoquery1.open;
End;
Stringlist.free
//I can populate the DBGRID with a single SQL query entered directly from the ADOQUERY1 property so my connections are good but my logic is probably twisted somewhere.
I've stepped traced through the code and it's properly getting a different value on each loop but ending with an empty DBGRID.
Is there an easier way?