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!
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try this:
objRS.Open "select * from my_table", objConn, adOpenDynamic, adLockOptimistic
Leon
objRS.Open "select * from my_table", objConn, adOpenDynamic, adLockOptimistic
Leon
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!
strConn = "Provider=SQLOLEDB" & _
";uid=MYID" & _
";pwd=MYPASSWORD" & _
";driver=SQL Server" & _
";server=SERVERNAME" & _
";database=DBNAME"
Thanks!
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!
:)
Many thanks, again!
:)
No problem. Good luck
Leon
Leon
ASKER
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!