Solved

Runtime error 3251 Current Recordset does not support updating

Posted on 2002-06-10
3
9,725 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 143

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to create a duplicate finder Application 9 122
A macro to Count the number of rows across all worksheets 3 128
MsgBox 2 59
Help me. 3 60
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

820 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