Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Editing ADO-recordset using code

Posted on 2000-02-25
9
Medium Priority
?
333 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
9 Comments
 

Expert Comment

by:jhedlund
ID: 2558391
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
ID: 2558397
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
ID: 2558405
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 4

Expert Comment

by:wesleystewart
ID: 2558423
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
 

Author Comment

by:Bebeirken
ID: 2558429
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
ID: 2558481
Show me how you declare connection and the way you open recordset.
0
 
LVL 4

Expert Comment

by:wesleystewart
ID: 2558510
Let's see some code.

Wes
0
 
LVL 2

Accepted Solution

by:
p_biggelaar earned 300 total points
ID: 2558563
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
ID: 2558631
p:

Good catch!

W
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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.
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 Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

722 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