I am using a connection object from code and a DataEnvironment in a VB application

Set CON = New ADODB.Connection
CON.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\AA.MDB;Persist Security Info=False"

Set RS = New ADODB.Recordset

If RS.State = 1 Then RS.Close
RS.ActiveConnection = CON
RS.CursorType = adOpenKeyset
RS.LockType = adLockPessimistic
RS.CursorLocation = adUseClient
RS.Open "Select * from emp"

It gives a error at last line
error :- No value given for one or more required parameters.

Sometimes it gives error
Operation is not allowed when the object is closed.

There is no problem with this piece of code. It is better to close the recordset and connection at the end.