Link to home
Start Free TrialLog in
Avatar of jdrits
jdrits

asked on

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!
ASKER CERTIFIED SOLUTION
Avatar of leonstryker
leonstryker
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jdrits
jdrits

ASKER

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!
Try this:

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

Leon
Avatar of jdrits

ASKER

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!
Avatar of jdrits

ASKER

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!

:)
No problem.  Good luck

Leon