[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1252
  • Last Modified:

Basic VB/ADO Record Edit

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
jdrits
Asked:
jdrits
  • 3
  • 3
1 Solution
 
leonstrykerCommented:
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
 
jdritsAuthor Commented:
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
 
leonstrykerCommented:
Try this:

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

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

 
jdritsAuthor Commented:
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
 
jdritsAuthor Commented:
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
 
leonstrykerCommented:
No problem.  Good luck

Leon
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now