Solved

Runtime error 3251 Current Recordset does not support updating

Posted on 2002-06-10
3
9,662 Views
Last Modified: 2011-08-18
The following is a chopped down version of my code... I have removed everything except the code dealing with the recordset...  Please let me know what I need to add to open this up in read/write.  (It stops on the rs.Addnew and displays the error Runtime error '3251' Current Recordset does not support updating.  This may be a limitation of the Provider, or of the select Locktype).

Thanks!
Matt

======== Code ==========
Dim cn As New ADODB.Connection
Dim rsMain As New ADODB.Recordset

cn.Open "Driver={Microsoft Access Driver (*.mdb)};Dbq=c:\Website Projects\ExitCashFlow\logMaster\Logs.mdb;"

strSQL = "Select * From Main Where Username = '" & strQuery & "' and Domain = '" & strDomain & "'"
   
Set rsMain = cn.Execute(strSQL)
   
If rsMain.EOF Then
     rsMain.AddNew
        rsMain(UserName) = strQuery
End If

rsMain.Close
Set rsMain = Nothing

======= End of Code =========
0
Comment
Question by:Voltec
3 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 100 total points
ID: 7066442
Try this:

Dim cn As ADODB.Connection
Dim rsMain As ADODB.Recordset

set cn = new ADODB.Connection
set rsMain = new ADODB.Recordset

cn.Open "Driver={Microsoft Access Driver (*.mdb)};Dbq=c:\Website Projects\ExitCashFlow\logMaster\Logs.mdb;"

strSQL = "Select * From Main Where Username = '" & strQuery & "' and Domain = '" & strDomain & "'"

rsMain.CursorType = adOpenKeyset
rsMain.Open cn, strSQL
   
If rsMain.EOF Then
    rsMain.AddNew
       rsMain(UserName) = strQuery
End If

rsMain.Close
Set rsMain = Nothing


CHeers
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 7066456
AngelIII is correct but to explain why:

The cn.Execute (strSQL) method returns a read-only recordset. Therefore it is not updatable. Using the .Open method on a recordset object allows you to specify the cursortype/location and locktype which you cannot do with the .Execute method. This is what angelIII shows. You can either set the recordset properties before opening the recordset as shown or using a single statement:

recordset.Open "SQL Statement",Connection,CursorType,LockType

The choice is yours.
0
 
LVL 3

Author Comment

by:Voltec
ID: 7068216
You actually reversed the connection and the SQL statement (the Open line should read rsMain.Open strSQL, cn) and that took me a few minutes to figure out why I was getting a '3001' error... but I fingered it out.  (=

Thanks for the Great info!

Matt
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now