Solved

Basic VB/ADO Record Edit

Posted on 2004-08-11
6
1,232 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
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
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.

 
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

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

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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 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…

896 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

12 Experts available now in Live!

Get 1:1 Help Now