Closing recordset generates exception
- From: "Hans van de Laar" <hansvandelaar@xxxxxxxxx>
- Date: Tue, 21 Aug 2007 14:29:17 -0700
Hi,
I want to create a new record within a Try Catch block using the
following code
Function Process() As Boolean
Dim rsAttendance As New clsMSRecordSet
Dim rs As ADODB.Recordset
rs = rsAttendance.recordset
Try
rs.Open("AANWREG", Conn)
rs.AddNew()
rs.Fields("ADM#").Value = mfldAttAdmID
rs.Fields("CURSUS#").Value = mfldAttCourseID
rs.Fields("EVENEM#").Value = mfldAttEventID
rs.Fields("DEELNEM#").Value = mfldAttParticipentID
rs.Fields("EV_PLN#").Value = mfldAttPlanItemID
rs.Update()
Process = True
Catch ex As System.Runtime.InteropServices.COMException
'TO DO : logging exception to xml file
Finally
If (rs.State = ADODB.ObjectStateEnum.adStateOpen)
Then rs.Close() < - generating exception
rsAttendance = Nothing
End Try
End Function
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?
I'm using VB.NET and Visual Studio 2005
Regards,
Hans van de Laar
.
- Follow-Ups:
- Re: Closing recordset generates exception
- From: Bob Barrows [MVP]
- Re: Closing recordset generates exception
- From: Stephen Howe
- Re: Closing recordset generates exception
- Prev by Date: Re: How does sql ExecuteReader() work?
- Next by Date: Re: Closing recordset generates exception
- Previous by thread: Re: Looking for code sample to inset master and detail typed recordset
- Next by thread: Re: Closing recordset generates exception
- Index(es):
Relevant Pages
|
|