Re: Closing recordset generates exception

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Hi Stephen,

Thanks for helping me.
May be I had to supply the source code of the recordset class I'm using
which sets the Cursorlocation, Cursortype and locktype properties.

Public Class clsMSRecordSet

Public Sub New()
MyBase.New()
With _rs
.CursorLocation = ADODB.CursorLocationEnum.adUseServer
.CursorType = ADODB.CursorTypeEnum.adOpenKeyset
.LockType = ADODB.LockTypeEnum.adLockOptimistic
End With
End Sub
Private _rs As New ADODB.Recordset

Public ReadOnly Property recordset() As ADODB.Recordset
Get
Return _rs
End Get
End Property
End Class

I'm rather new to .NET so if you can give me some good advise I really
appreciate this.

Thanks,
Hans

Stephen Howe wrote:


When the update fails I get a descriptive message but I an other
error "operation not allowed in this context" is thrown up when the
rs.Close() is issued. Any idea why is this happening?

Your RecordSet Open is deficient.
The RecordSet will be being open in ReadOnly mode as that is the
default LockType. Naturally that will prevent an Update().

For this:

rs.Open("AANWREG", Conn)

is ADO supposed to guess that "AANWREG" is a table?

Why arent you specifying CursorLocation, LockType, CursorType and
additional arguments telling ADO what "AANWREG" is? Open() is the
most important call of a Recordset, it affects various properties,
behaviour of methods, it is crazy to allow default arguments. It also
affects performance.

Cheers

Stephen Howe
.



Relevant Pages

  • Re: Stored Procedures and RecordSets
    ... Do I setup CursorLocation, CursorType, LockType ... Retrieving a recordset from a stored ... If the Recordset was Server-sided, Forward-only, Read-only, then a cursor has to be opened SQL Server. ...
    (microsoft.public.data.ado)
  • Re: Updating An ADO 2.6 Recordset With VB and Access
    ... Depends on how you open the recordset. ... values for CursorLocation, CursorType, and LockType, is a read-only, ... > Is an ADO 2.6 Recordset from an access database updatable? ...
    (microsoft.public.data.ado)
  • Re: ADO Recordset vs Command and AD
    ... The CursorLocation can be set on the connection prior to opening the ... This CursorLocation is applied to the recordset opened on this ... Open method of a Recordset object, so you can assign the cursorType ... CommandText property of a Command object so you can turn on paging and use ...
    (microsoft.public.scripting.vbscript)
  • Re: Current Recordset does not support updating.
    ... it may be a limitation of your ... > that the recordset is editable. ... > above CursorLocation to see if problem went away, ... I changed the CursorType to adOpenKeyset. ...
    (microsoft.public.vb.database.ado)
  • Re: Return a recordset from an MDB
    ... Is it necessary to specify a CursorLocation? ... Execute method of the Command object to return a Recordset, ... If you use a Connection object, ...
    (microsoft.public.scripting.vbscript)