![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 9 of 9 total |
![]() |
Thu, May 29 2008 5:23 PM | Permanent Link |
"M.E." | I'm getting an EListError with message List Index Out Of Bounds (2) when I
try to open a table I just created programmatically. The form already has a TDbisamTable component to which I refer at the creation routine: with TableMem do begin If Exists then begin Close; DeleteTable; end; Active := False; DatabaseName := 'MEMORY'; TableName := 'Mem.dat'; with FieldDefs do begin Clear; Add('Selecionado',ftBoolean,0,False); For i := 0 to Length(Campo)-1 do Add(Campo[i], ftString, Tamanho[i], False); end; {With FieldDefs] with IndexDefs do begin Clear; Add('','Codemp', [ixPrimary, ixUnique]); end; CreateTable; Close; end; That creation routine looks normal to me, mainly because after the error the table seems to open normally and I am even able to populate it. How to avoid that error? Thanks Marcio |
Fri, May 30 2008 12:11 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Marcio,
<< I'm getting an EListError with message List Index Out Of Bounds (2) when I try to open a table I just created programmatically. The form already has a TDbisamTable component to which I refer at the creation routine: >> Did you step through this in the debugger to see what line the error occurs on ? -- Tim Young Elevate Software www.elevatesoft.com |
Fri, May 30 2008 12:46 PM | Permanent Link |
M.E. | On TableMem.Open;
Just that. There is no error at those lines while creating the table. The table seems to be perfectly created but raises the error when at the line TableMem.Open. Marcio "Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote: Did you step through this in the debugger to see what line the error occurs on ? |
Fri, May 30 2008 12:57 PM | Permanent Link |
"Robert" | "M.E." <no@no.com.br> wrote in message news:495C992B-D4AC-452B-B096-83DC08BCBA24@news.elevatesoft.com... > I'm getting an EListError with message List Index Out Of Bounds (2) when I > try to open a table I just created programmatically. > end; {With FieldDefs] There doesn't seem to be anything wrong with your code, except for the closing comment parenthesis after With FieldDefs. You need to find out exactly where the error occurs, there's something else here. Of course, if the ] at the end of With FieldDefs is not a typo but is actually in your code, all bets are off because anything following that is considered a comment. Robert |
Fri, May 30 2008 2:43 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Marcio,
<< On TableMem.Open; Just that. There is no error at those lines while creating the table. The table seems to be perfectly created but raises the error when at the line TableMem.Open. >> If you want to send me something that reproduces this, I'll be happy to tell you what the problem is. Your code, as far as I can see, is fine (apart from the comments issue that Robert mentioned), so something else must be going on that isn't readily visible by the code that you posted. -- Tim Young Elevate Software www.elevatesoft.com |
Fri, May 30 2008 4:07 PM | Permanent Link |
"M.E." | That was a typo (I forgot to press shift when typing "}"), but your comment
made me think about the brackets. Well, since I am getting a "list index out-of-bounds" error, there likely be something about the arrays I am using to populate the FieldsDefs, right? I have two arrays, Campo[] and Tamanho[], which are the same size (30 items). That's why my loop goes from 0 to Length(Campo)-1, since arrays start their count at 0. with FieldDefs do begin Clear; Add('Selecionado',ftBoolean,0,False); For i := 0 to Length(Campo)-1 do Add(Campo[i], ftString, Tamanho[i], False); end; {With FieldDefs} This code also looks ok to me. Nevertheless, I took those loop lines off, and bingo, the error disappeared. So, there is really something wrong with that use of loop/arrays to create fields. But I can't figure what it is. Worst: why the error is raised only when I try to open the table after the process and not when the table is created? Any idea? Marcio "Robert" <ngsemail2005withoutthis@yahoo.com.ar> escreveu: > There doesn't seem to be anything wrong with your code, except for the > closing comment parenthesis after With FieldDefs. You need to find out > exactly where the error occurs, there's something else here. |
Fri, May 30 2008 5:12 PM | Permanent Link |
"Robert" | "M.E." <no@no.com.br> wrote in message news:E2C38B09-A79D-449E-9D35-B1CB195C8729@news.elevatesoft.com... > So, there is really something wrong with that use of loop/arrays to create > fields. > But I can't figure what it is. There's nothing wrong with using a loop like that. It is something odd with the data you have in the arrays that is causing the problem. Probably in the campo array, since sizes are edited fairly well when you create a field. Somehow the data passes the create field edit, but causes a problem when you open the table. Take a look at each field as you add it (both field name and size), and hopefully it should be obvious. Please post the result here so we'll know, thanks. Another possiblity is any code in beforeopen or afteropen. Trying to index thru nonexisting data, or something like that. Robert |
Fri, May 30 2008 8:57 PM | Permanent Link |
"M.E." | I found out.
There was another possibility none of us never expected to be: a component failure. The error was being raised by an InfoPower wwDbGrid linked to the dataset. That was why the error only showed up when trying to open the table. Since a regular DbGrid works perfectly linking to a table created on the fly (without previously defining fields a.s.o.), I thought the wwDbGrid would do the same and included it in this project. I solved the puzzle when I saved the same unit/form to a new project to test it separatedly and deleted the wwDbGrid. No error was raised anymore. So, logic showed me where the problem was. Well, Robert and Tim, sorry for the inconvenience. It looks like I need to learn more about wwDbGrid. Thanks anyway, Marcio "Robert" <ngsemail2005withoutthis@yahoo.com.ar> escreveu: > Somehow the data passes the create field edit, but causes a problem when > you open the table. Take a look at each field as you add it (both field > name and size), and hopefully it should be obvious. Please post the result > here so we'll know, thanks. > Another possiblity is any code in beforeopen or afteropen. Trying to index > thru nonexisting data, or something like that. |
Mon, Jun 2 2008 11:10 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Marcio,
<< So, logic showed me where the problem was. Well, Robert and Tim, sorry for the inconvenience. It looks like I need to learn more about wwDbGrid. >> No problem, I'm glad that you found the source of the issue, and thanks for updating us on the situation. -- Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Wednesday, August 14, 2024 at 03:12 PM | Privacy Policy![]() © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |