Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Editing ADO-recordset using code

Posted on 2000-02-25
9
Medium Priority
?
335 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
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 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…
Suggested Courses

916 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