ErrMsg: Resource exceed limit.


I'm writing a program that read from several AS400 files, doing simple
calculation, than insert the result record into one table of MsSQL server
6.5.  That result table should contains about 7000 records, each record
about 300bytes.  In the middle of the process (about 3xxx records
processed), the program stop and return a error message: RESOURCE EXCEED
LIMIT,  I would like to know what is the problem? Lack of memory?
My program like this:

TQuery B contains an insert statement
Open TQuery A from as400
while not A.eof do
   B.fields[n1].value := f1(A.fields[n1].value) ; // this function may open
another MsSQL file for retrieving information.
   B.fields[n2].value := f2(A.fields[n2].value) ; // this function may open
another AS400 file for retrieving information.
   // About 8 functions used

TQueris C, D...(in functions) are VCLs, They have not created and free in
the process.
A, B, C... is normal TQueries, not T400Query or T400Files.

When I remark a function, the program can process 1000 more records.
I have tried to use Transaction, but it doesn't help.

If you need more information about the program, please let me know.

Best Regard.