Error when deleting last record

G

Guest

I have an error when I try to delete last record in the record set. The code
I'm using is:
lcurrow = Me.BindingContext(DsTextProdMain,
"TextProductsMain").Current
lcurrow.Delete()
This code works for all records in the recordset except last one. But if
recordset contains only one record the code works fine. The error is coming
out only in 2003 version, 2002 version works fine.

The system give me a not understandable error.

An unhandled exception of type 'System.NullReferenceException' occurred in
system.data.dll

Additional information: Object reference not set to an instance of an object.

Is somebody met this behabior?
 
B

Bernie Yaeger

Hi Bronislav,

Sounds strange. You say 'recordset', so I have to ask - are you using ado
or ado.net? If ado.net, I'd recommend you post to
microsoft.public.dotnet.adonet.

Bernie Yaeger
 
G

Guest

Hi Bernie
I'm using ado.net
Thanks, Bronislav.

Bernie Yaeger said:
Hi Bronislav,

Sounds strange. You say 'recordset', so I have to ask - are you using ado
or ado.net? If ado.net, I'd recommend you post to
microsoft.public.dotnet.adonet.

Bernie Yaeger
 
C

Cor Ligthert

Bronislav,

As Bernie wrote is using a recordset ADODB,.

However I dont believe you are using a recordset, so please do not write
that next time.

A recordset has absolute no equalitiys with a dataset. One of the aspects is
by instance that a recordset is only one connected datatable. (While a
datatable in a dataset is disconnected).

Did you try already something as this. (Changed in this message so watch
typos or whatever).
\\\
Dim cm As CurrencyManager = _
DirectCast(BindingContext(DsTextProdMain," TextProductsMain").dtVBreg),
CurrencyManager)
If DsTextProdMain.tables("TextProductsMain").rows.Count > 0 Then
DsTextProdMain.tables("TextProductsMain").rows(cm.Position).Delete()
End If
///

Be aware I tried to take the datasource as you used in your message, I do
not know if that is the used one.

I hope this helps?

Cor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top