Question Operation is Not allowed when the object is open

Knvn

Well-known member
Joined
Dec 30, 2009
Messages
45
Programming Experience
Beginner
I want to open a recordset by using following code:

srs.Open("select * from " & settings.Fields(1).Value & " where Name LIKE '" & Search.Text & "%'", cnn, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic)

But it generates an exception such as 'Operation is Not allowed when the object is open'

It would be fine When I use the following code:

srs.Open("select * from " & settings.Fields(1).Value, cnn, CursorTypeEnum.adOpenDynamic, LockTypeEnum.adLockOptimistic)

Pls help me........
 
What antiqated database technology is that?!

Are you following a VB6 tutorial from from mid eighties or something?
 
No I didn’t refer any book. Now my problem is solved, actually I got this error because; I forgot to close the record set on the iteration. (The Query I wrote on the question is under the loop.)
 
Back
Top