Solved

Editing ADO-recordset using code

Posted on 2000-02-25
9
325 Views
Last Modified: 2010-05-02
I want to edit an ADO-recordset just by using code.

I have this book that suggest the following code :

m_recTitle.Edit
m_recTitles("Title") = "We all love VB6"
m_recTitles.update

When I use this in my code, I get the message, that the edit is not a valid method.
If I leave the edit out, it tells me my provider does not allow that action.
My provider is Microsoft Jet OLEDB 4.0

What is the right way to edit my recordset through code?

Thanks.
0
Comment
Question by:Bebeirken
  • 3
  • 2
  • 2
  • +2
9 Comments
 

Expert Comment

by:jhedlund
Comment Utility
There is no ".Edit" method when using ADO Recordsets (at least in v2.0+).  

Remove the .Edit, and everything should work just fine.
0
 
LVL 6

Expert Comment

by:Marine
Comment Utility
ADO doesn't support edit method. It accpets a direct field assigning.
so if you have it like this it will work
m_rectitle("title) = "we love VB"
m_rectitles.update
it will work and updata a record
0
 

Expert Comment

by:jhedlund
Comment Utility
Oh, I meant to select that as "Answer", but anyway...

I thought I'd add one more comment:  When you begin to edit a recordset (By assigning a value to a field, as in your second line "m_recTitles("Title") = 'We all Love VB6'") that starts the "edit" session.  

With DAO, you had to issue an .Edit to begin the edit session.  With ADO, you just set a value to a field, and that begins it.  You can still .CancelUpdate to remove changes since a edit has begun, or .Update to save the changes.
0
 
LVL 4

Expert Comment

by:wesleystewart
Comment Utility
REmember that if you leave the record (with a .movenext, perhaps) you will write the record even if you don't call the .update method explicitly.  This is different than DAO and causes a lot of problems for people switching Data Access providers.

You said:

"My provider is Microsoft Jet OLEDB 4.0" but are you sure you opened an ADO recordset?  Just one thing to check.

Wes
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:Bebeirken
Comment Utility
Thanks for the comments.

I allready tried it without the edit.

But I still get the message:
Runtime error '3251':
The operation requested by the application is not suported by the provider.

Any suggestions?
0
 
LVL 6

Expert Comment

by:Marine
Comment Utility
Show me how you declare connection and the way you open recordset.
0
 
LVL 4

Expert Comment

by:wesleystewart
Comment Utility
Let's see some code.

Wes
0
 
LVL 2

Accepted Solution

by:
p_biggelaar earned 100 total points
Comment Utility
The default cursortype doesn't allow you to update the recordset.

Before you OPEN the recordset, add these lines:

m_rectitles.CursorType=adKeySet
m_rectitles.CursorLocation=adUseClient
m_rectitles.LockType=adLockOptimistic

Now you should be able to update your recordset!

0
 
LVL 4

Expert Comment

by:wesleystewart
Comment Utility
p:

Good catch!

W
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

763 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

7 Experts available now in Live!

Get 1:1 Help Now