Monday, December 17, 2007

How to solve the LockType problem in ASP scripts?

How to solve the LockType problem in ASP scripts?


Below is the ASP scripts which contain LockType problem:



<%

const adOpenReadOnly = 1

Set conn = Server.CreateObject("Adodb.Connection")

conn.Open "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("db1.mdb")

      Set rs = Server.CreateObject("Adodb.Recordset")

rs.Open "Stock",conn,1,adOpenReadOnly ‘The error will occur here

rs.addNew

rs.fields("ProductName") = "Music"

rs.fields("Price") = 12.30

rs.update

rs.Close

Set rs = Nothing

%>

The problem in this script is the LockType is set to the adOpenReadOnly.

In this kind of Lock type, we can make any modification or update the information in the recordset. So change the LockType will solve the problem.

No comments: