We help IT Professionals succeed at work.

Is rs.edit posible?

matrix717
matrix717 asked
on
Normally I use this to add a new record:

Dim cn
Dim rs
Dim ubi1

Set cn=Server.CreateObject("ADODB.connection")
Set rs= Server.CreateObject("ADODB.Recordset")

ubi1="c:\data.mdb"

cn.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & ubi1 & ";uid=;pwd="

sql="select * from products"

rs.Open sql, cn, 3, 3

rs.addnew
rs.fields("activate")=request.form("activate")
...


Adn it works great, but when I try to use the .edit  for example:

...
rs.edit
rs.fields("activate")=request.form("activate")
...
rs.update
...

IT Doesnt work... WHY?
Comment
Watch Question

CERTIFIED EXPERT
Commented:
Are you trying to do an insertion of record? For insertion of records, do this

rs.addnew
rs.fields("activate")=request.form("activate")
...


For update of records, do this
rs.fields("activate")=request.form("activate")
rs.update

Note that the record where the cursor is will be updated.

hongjun
ADO does NOT have an EDIT method on the recordset object.

However, make sure that you open the recordset with The proper Locking Level, as you appear to be doing.

CERTIFIED EXPERT

Commented:
Exactly :)

hongjun

Author

Commented:
How can I set a that "proper Locking Level" what it is?

Author

Commented:
How can I set a that "proper Locking Level" what it is?
CERTIFIED EXPERT

Commented:
Locking level is the value of the 4th parameter of the rs.Open. For your code, you gave it a value of 3 which is correct. You should not use a value of 1 because value 1 will make the recordset with readonly lock.

hongjun
CERTIFIED EXPERT

Commented:
Read this for information of the LockType property.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/his/thorref4_4puq.asp

hongjun
A request has been made (http://www.experts-exchange.com/cleanup/Q_20320237.html) that this question be closed with the following resolution: points to hongjun

EXPERTS: Please leave any comment regarding this request here; I will return in seven (7) days to close the question.

Netminder
CS Moderator
CERTIFIED EXPERT

Commented:
7 days has passed I recommend points to hongjun.

hongjun
Per recommendation, force-accepted.

Netminder
CS Moderator

Explore More ContentExplore courses, solutions, and other research materials related to this topic.