Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CursorType & LockType property

Status
Not open for further replies.

scribbler

MIS
Feb 4, 2002
206
GB
Can anyone point me in the right direction. I'm trying to delete a record from my database and get the error below. I think it is to do with CursorType & LockType property but have looked around the web for teh various type descriptions without finding my answer.


Microsoft OLE DB Provider for ODBC Drivers error '80004005'

[Microsoft][ODBC Microsoft Access Driver] Cannot update. Database or object is read-only.

/removeme.asp, line 102



My code is made up of the following....
Dim Con
Connection Object
Dim contactsRS
Dim contactsSQL
'open Database and set record set
Set Con = Server.CreateObject("ADODB.Connection")
Con.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("contacts.mdb")
Set contactsRS = Server.CreateObject("ADODB.Recordset")
'Find the email address and ID from the table that matches the request query strting fields
contactsSQL = "SELECT * FROM tblcontacts WHERE EmailAddress='" & Trim(Request.QueryString("emailaddress")) & "' AND ID=" & CInt(Request.QueryString("ID")) & ";"
contactsRS.LockType=3
contactsRS.CursorType=2
contactsRS.Open contactsSQL, con
contactsRS.delete
 
OK - here is a much more efficient way to DELETE records from a database. You dont need to create a recordset unless you are retrieving info from the database.
Code:
Dim Con             
Set Con = Server.CreateObject("ADODB.Connection")
Con.Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("contacts.mdb"))

strDeleteSQL = "DELETE FROM tblcontacts WHERE EmailAddress='" & Trim(Request.QueryString("emailaddress"))  & "' AND ID=" & CInt(Request.QueryString("ID"))  & ";"

Con.Execute(strDeleteSQL)

Con.Close
Set Con = Nothing

Tony
_______________________________________________________________
 
Another problem that sometimes happens with file based databases like MS Access is that the default IIS account, IUSR_MachineName might not have full access to the file.

In these cases you can waste a day looking for a problem in your code and it turns out to be a file permissions issue on the server.
 
Ok Cheers for that Guys.

I will ammend my code as per FesterSXS suggests and will contact my provider to see if thats the case as described by Sheco and let you know the outcome
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top