Solved

Basic VB/ADO Record Edit

Posted on 2004-08-11
6
1,229 Views
Last Modified: 2013-12-25
Greetings!

I am trying to do a very basic edit of a record using ADO and VB 6 Enterprise:

Set objConn = New ADODB.Connection
objConn.Open strConn
Set objRS = New ADODB.Recordset
objRS.Open "select * from my_table", strConn
objRS.MoveFirst
objRS.Edit

objRS("Field1") = MyValue

objRS.Update
objRS.Close

---etc.---

The problem is that when VB hits the objRS.Edit I get "method or data member not found."

Aside from using a SQL update (I need to mahually loop through the records and perform lots of calcs), what's the right way to do an edit with ADO. I've always used it before like that, but maybe it was DAO in the past.

Thanks!
0
Comment
Question by:jdrits
  • 3
  • 3
6 Comments
 
LVL 29

Accepted Solution

by:
leonstryker earned 500 total points
Comment Utility
There is no Edit method/property.  Take a look here on how the Update method works:

http://www.activeserverpages.ru/ADO/dameth03_5.htm

Basically in your code, just take out that line.

Leon
0
 
LVL 2

Author Comment

by:jdrits
Comment Utility
Thanks, Leon. I took that line out, but as soon as I try to update a field, I get "Current recordset does not support updating. This may be a limitation of the provider, or of the selected locktype."

I've tried every variation of cursor and lock type, but I always get that message. The database I am trying to update is SQL Server 2000.

Am I missing something?

Thanks!
0
 
LVL 29

Expert Comment

by:leonstryker
Comment Utility
Try this:

objRS.Open "select * from my_table", objConn, adOpenDynamic, adLockOptimistic

Leon
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 2

Author Comment

by:jdrits
Comment Utility
Thanks. I did try that. If this helps, strConn is equal to the following:


strConn = "Provider=SQLOLEDB" & _
                      ";uid=MYID" & _
                      ";pwd=MYPASSWORD" & _
                      ";driver=SQL Server" & _
                      ";server=SERVERNAME" & _
                      ";database=DBNAME"

Thanks!
0
 
LVL 2

Author Comment

by:jdrits
Comment Utility
Thanks for your help, Leon. When i took out the provider, it now works fine. Not sure why, but as long as it works, I'm good to go. I may revisit this at some point to find out why, but for now I am on a tight deadline.

Many thanks, again!

:)
0
 
LVL 29

Expert Comment

by:leonstryker
Comment Utility
No problem.  Good luck

Leon
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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.
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…
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…

772 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

11 Experts available now in Live!

Get 1:1 Help Now