Solved

Editing ADO-recordset using code

Posted on 2000-02-25
9
326 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
 
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
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.

 

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 100 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

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

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

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