Connecting Tech Pros Worldwide Help | Site Map

Current Recordset does not support updating

Member
 
Join Date: Aug 2007
Posts: 89
#1: Sep 3 '07
Hi,

I get the following error on the last line:

Run-time error '3251':

Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype.

Expand|Select|Wrap|Line Numbers
  1.     ' Open database connection
  2.     Set adoConn = CreateObject("ADODB.Connection")
  3.     adoConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " & strArchivePath & "mailarchive.mdb" & ";User ID=Admin;Password=;"
  4.     adoConn.Open
  5.  
  6.     ' Open recordset
  7.     Set adoRecSet = New ADODB.Recordset
  8.     adoRecSet.Open "SELECT * FROM tblEmail ORDER BY ISS ASC", adoConn, adOpenKeyset, adLockOptimistic
  9.  
  10. adoRecSet.MoveLast
  11. adoRecSet.AddNew
I did some searches in this forum, but setting the locktype to adLockOptimistic apparently does not help... What do I do wrong with this one?
QVeen72's Avatar
Moderator
 
Join Date: Oct 2006
Location: Bangalore
Posts: 1,385
#2: Sep 3 '07

re: Current Recordset does not support updating


Hi,

Change this :


Expand|Select|Wrap|Line Numbers
  1. adoRecSet.Open "SELECT * FROM tblEmail ORDER BY ISS ASC", adoConn, adOpenDynamic, adLockOptimistic
  2.  
Change KeySet to Dynamic..

REgards
Veena
Member
 
Join Date: Aug 2007
Posts: 89
#3: Sep 3 '07

re: Current Recordset does not support updating


Quote:

Originally Posted by QVeen72

Hi,

Change this :


Expand|Select|Wrap|Line Numbers
  1. adoRecSet.Open "SELECT * FROM tblEmail ORDER BY ISS ASC", adoConn, adOpenDynamic, adLockOptimistic
  2.  
Change KeySet to Dynamic..

REgards
Veena

I did, but still get the same error... :S
QVeen72's Avatar
Moderator
 
Join Date: Oct 2006
Location: Bangalore
Posts: 1,385
#4: Sep 3 '07

re: Current Recordset does not support updating


Quote:

Originally Posted by BlackMustard

Hi,

I get the following error on the last line:

Run-time error '3251':

Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype.

Expand|Select|Wrap|Line Numbers
  1.     ' Open database connection
  2.     Set adoConn = CreateObject("ADODB.Connection")
  3.     adoConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " & strArchivePath & "mailarchive.mdb" & ";User ID=Admin;Password=;"
  4.     adoConn.Open
  5.  
  6.     ' Open recordset
  7.     Set adoRecSet = New ADODB.Recordset
  8.     adoRecSet.Open "SELECT * FROM tblEmail ORDER BY ISS ASC", adoConn, adOpenKeyset, adLockOptimistic
  9.  
  10. adoRecSet.MoveLast
  11. adoRecSet.AddNew
I did some searches in this forum, but setting the locktype to adLockOptimistic apparently does not help... What do I do wrong with this one?

Hi,

Why are u "Late Binding" the Object by creating...?

Directly Declare :
Dim adoConn As New ADODB.Connection
Dim adoRecSet As New ADODB.RecordSet

And Check "strArchivePath" Should have last Char ="\" some thing like :
C:\MyFolder\Data\

Regards
Veena
QVeen72's Avatar
Moderator
 
Join Date: Oct 2006
Location: Bangalore
Posts: 1,385
#5: Sep 3 '07

re: Current Recordset does not support updating


Hi,

What Version of ADO Objects u have Included in ur proj..?

It Should be :
"Microsoft ActiveX Data Objects 2.0 Library"

or Higher..

REgards
Veena
Member
 
Join Date: Aug 2007
Posts: 89
#6: Sep 3 '07

re: Current Recordset does not support updating


I have included a library called "Microsoft ActiveX Data Objects 2.7 Library", and I changed the declarations in (General) to the following:

Expand|Select|Wrap|Line Numbers
  1. Dim adoConn As New ADODB.Connection
  2. Dim adoRecSet As New ADODB.RecordSet
In my code, i then removed the "Set" commands, leaving the code at

Expand|Select|Wrap|Line Numbers
  1.     ' Open database connection
  2.     adoConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source = " & strArchivePath & "mailarchive.mdb" & ";User ID=Admin;Password=;"
  3.     adoConn.Open
  4.  
  5.     ' Open recordset
  6.     adoRecSet.Open "SELECT * FROM tblEmail ORDER BY ISS ASC", adoConn, adOpenDynamic, adLockOptimistic
  7.  
  8.     ' Add record
  9.     adoRecSet.MoveLast
  10.     adoRecSet.AddNew
I still get the same error...

EDIT:
strArchivePath is previously set directly in code, and does end with a "\". I use a variable just to make it easier to change if i want to use this sub somewhere else.
Member
 
Join Date: Aug 2007
Posts: 89
#7: Sep 4 '07

re: Current Recordset does not support updating


I found the error - I was using the same recordset in another function, so the adoRecSet variable didn't contain what i thought it did. Problem solved by using a separate recordset.
QVeen72's Avatar
Moderator
 
Join Date: Oct 2006
Location: Bangalore
Posts: 1,385
#8: Sep 4 '07

re: Current Recordset does not support updating


Hi,

Good u solved, if that was the Case, then u can overcome that problem, by Setting the Recset = Nothing before opening it..:

Set RS =Nothing
and then Open :
RS.Open strSQL, AConn

REgards
Veena
Member
 
Join Date: Aug 2007
Posts: 89
#9: Sep 4 '07

re: Current Recordset does not support updating


Quote:

Originally Posted by QVeen72

Hi,

Good u solved, if that was the Case, then u can overcome that problem, by Setting the Recset = Nothing before opening it..:

Set RS =Nothing
and then Open :
RS.Open strSQL, AConn

REgards
Veena

Well, now i've already emailed the macro out to the entire department =) But this is worth remembering for next time... Does it optimize the prestanda compared to using several different recordsets?
Newbie
 
Join Date: Jun 2009
Posts: 1
#10: Jun 19 '09

re: Current Recordset does not support updating


Download this instructions
hope it will help you
Download Link
Reply