Index out of bounds when putting client data set in edit mode

Index out of bounds when putting client data set in edit mode

Post by smvelos » Wed, 16 Feb 2005 04:39:37


Hi,

I am new to Delphi, so I apologize if this is a silly question...

I have a form with just two data-aware controls (TDBEdit), a client
data set and a data source. When I try to edit the values in the
dbedits I get an Exception stating "List index out of bounds (-1)".

While debugging, I found that the exception occurs when the dataset
itself is put in edit mode (so if I call dataset.Edit that causes the
exception).

If I call dataset.disablecontrols and change the value in the data
field programatically, it all works just fine.

Does anybody have a clue about what might be happening ? I would
really appreciate any hint that might help me find out what going
on...

Thanks,
Sergio
 
 
 

Index out of bounds when putting client data set in edit mode

Post by Dan » Thu, 17 Feb 2005 04:54:48


There are no silly questions, only silly answers...

How are you navigating through the dataset? Have you tried something
like:
dataset.first;
dataset.edit;

There are many places where a list is created by a component, but we
don't see it explicitly. So, when we use the component incorrectly, we
can get a out of bounds error.

HTH,
Dan

 
 
 

Index out of bounds when putting client data set in edit mode

Post by smvelos » Fri, 18 Feb 2005 07:41:29

Hi Dan,

Thank you very much for the reply !

It turned out that there was a data-aware control "hidden" in
another tab (in a very confuse form) that I was not aware of... and
that was linked to the dataset. I still don't know why the exception
occurs, but for now I do not have to (I simply unlinked it).

Oh, that explains why "disablecontrols" before editing worked.

As I said, I am new to Delphi, but I was wondering that there might
be some more information when exceptions are raised (something like
exception nesting in Java). But maybe it is only my inexperience. :-)

Thank you !
Sgio
 
 
 

Index out of bounds when putting client data set in edit mode

Post by Dan » Fri, 18 Feb 2005 09:55:43


<snip>
When you run the application from the Delphi IDE, and have debug info
turned on, you will see all of the exceptions as they happen, along
with the source code where the exception takes place. I'm not familiar
with Java, so I can't say if this is equivalent.

Glad to help,
Dan