Solved

Basic VB/ADO Record Edit

Posted on 2004-08-11
6
1,240 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
[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
  • 3
6 Comments
 
LVL 29

Accepted Solution

by:
leonstryker earned 500 total points
ID: 11778051
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
ID: 11778694
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
ID: 11779196
Try this:

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

Leon
0
Technology Partners: 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 2

Author Comment

by:jdrits
ID: 11779224
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
ID: 11779273
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
ID: 11779423
No problem.  Good luck

Leon
0

Featured Post

Industry Leaders: 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!

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
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…
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…
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…

726 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