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
Solved

Editing ADO-recordset using code

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

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…
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…

808 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