🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.delphi.database.dotnet
4 messages
4 total messages Started by Brigitte Spatz Wed, 10 Jan 2007 13:49
"Index 1 is not non-negative and below total rows count"
#10
Author: Brigitte Spatz
Date: Wed, 10 Jan 2007 13:49
12 lines
1361 bytes
I use the following common code from about 20 forms to insert a new 
record into an SQL Server 2005 DB. In all but one it works. In one I get 
the above error message in the third line.
     dv.AllowNew := true; //dv = DataView
     bm.AddNew; //bm = BindingManager
     with dv.Item[bm.Position].Row do

Inspecting shows bm.Position to be correct. What could be wrong here?

TIA.

Brigitte
Re: "Index 1 is not non-negative and below total rows count"
#11
Author: Marc Rohloff TeamB
Date: Wed, 10 Jan 2007 19:25
14 lines
1537 bytes
On Wed, 10 Jan 2007 14:49:23 +0100, Brigitte Spatz wrote:

>      bm.AddNew; //bm = BindingManager
>      with dv.Item[bm.Position].Row do
> 
> Inspecting shows bm.Position to be correct. What could be wrong here?

What are the values of bm.Position and dv.Count?

Have you tried calling dv.AddNew instead?

-- 
Marc Rohloff [TeamB]
marc rohloff -at- myrealbox -dot- com
Re: "Index 1 is not non-negative and below total rows count"
#13
Author: Brigitte Spatz
Date: Fri, 12 Jan 2007 06:55
22 lines
1984 bytes
Marc Rohloff [TeamB] wrote:
> On Wed, 10 Jan 2007 14:49:23 +0100, Brigitte Spatz wrote:
> 
>>      bm.AddNew; //bm = BindingManager
>>      with dv.Item[bm.Position].Row do
>>
>> Inspecting shows bm.Position to be correct. What could be wrong here?
> 
> What are the values of bm.Position and dv.Count?

Immediately after bm.AddNew bm.Position is 1 and so is dv.count, but 
only in that one form, in all others it's 2 (or in general bm.Position + 1).

> 
> Have you tried calling dv.AddNew instead?
> 
Yes. I get "Object reference not set to an instance of an object" 
instead (in the one form, not in the others). And while there's a new 
entry in the grid, it doesn't have an ID, which is supposed to come from 
the database (an identity field) (in all forms).

Brigitte
Re: "Index 1 is not non-negative and below total rows count"
#14
Author: Brigitte Spatz
Date: Fri, 12 Jan 2007 07:51
31 lines
2186 bytes
Brigitte Spatz wrote:
> Marc Rohloff [TeamB] wrote:
>> On Wed, 10 Jan 2007 14:49:23 +0100, Brigitte Spatz wrote:
>>
>>>      bm.AddNew; //bm = BindingManager
>>>      with dv.Item[bm.Position].Row do
>>>
>>> Inspecting shows bm.Position to be correct. What could be wrong here?
>>
>> What are the values of bm.Position and dv.Count?
> 
> Immediately after bm.AddNew bm.Position is 1 and so is dv.count, but 
> only in that one form, in all others it's 2 (or in general bm.Position + 
> 1).
> 
>>
>> Have you tried calling dv.AddNew instead?
>>
> Yes. I get "Object reference not set to an instance of an object" 
> instead (in the one form, not in the others). 

Disregard this, it was coming from elsewhere.

And while there's a new
> entry in the grid, it doesn't have an ID, which is supposed to come from 
> the database (an identity field) (in all forms).
Furthermore, the row at position bm.position in the grid is being 
overwritten rather than the new record filled, even though I used
with dv.Item[dv.Count - 1].Row do

Brigitte
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads