Problem with updating
Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=18724
Printed Date: 29 March 2026 at 7:45pm Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com
Topic: Problem with updating
Posted By: BlackGoldFish
Subject: Problem with updating
Date Posted: 15 March 2006 at 3:56pm
Hi, I was doing the guestbook asp tutorial available on this site and everything worked fine up until I tried to do the updating section. I have made a few cosmetic changes but nothing major. I can select the entry I wish to update and fill in the form stating what I want it changed to but when I try to submit it I get the following error:
ADODB.Recordset (0x800A0CB3) Current Recordset does not support updating.
This may be a limitation of the provider, or of the selected locktype.
The piece of code in question looks like this. 'Update the record in the recordset rsUpdateEntry.Fields("Name") = Request.Form("name") rsUpdateEntry.Fields("Surname") = Request.Form("surname")
I'm running this with an access database on a windows 2000 machine. I'm not realy into programming but if anyone can suggest something that isn't too technical I'd really appreciate it.
|
Replies:
Posted By: site master
Date Posted: 16 March 2006 at 12:05pm
if i understand you currectly
you have wrong locktype...
i think you wrote somthing like this: rs.open .....,con,3,1
locktype number 1 does not support updating put the locktype to 3 and i think it will work
-------------
|
Posted By: BlackGoldFish
Date Posted: 16 March 2006 at 2:17pm
I'm not really sure what you mean, but then again I know nothing about ASP, I only started using it on Monday. This is all of my code for that page. It should give you abetter idead of what I was doing then I could.
<% 'Dimension variables Dim adoCon 'Holds the Database Connection Object Dim rsUpdateEntry 'Holds the recordset for the record to be updated Dim strSQL 'Holds the SQL query to query the database Dim lngRecordNo 'Holds the record number to be updated
'Read in the record number to be updated lngRecordNo = CLng(Request.Form("IDNum"))
'Create an ADO connection object Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("tester.mdb")
'Create an ADO recordset object Set rsUpdateEntry = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database strSQL = "SELECT tblNames.* FROM tblNames WHERE IDNum=" & lngRecordNo
'Set the cursor type we are using so we can navigate through the recordset rsUpdateEntry.CursorType = 2
'Open the recordset with the SQL query rsUpdateEntry.Open strSQL, adoCon
'Update the record in the recordset rsUpdateEntry.Fields("Name") = Request.Form("name") rsUpdateEntry.Fields("Surname") = Request.Form("surname")
'Write the updated recordset to the database rsUpdateEntry.Update
'Reset server objects rsUpdateEntry.Close Set rsUpdateEntry = Nothing Set adoCon = Nothing
'Return to the update select page in case another record needs deleting Response.Redirect "update_select.asp" %>
|
Posted By: site master
Date Posted: 16 March 2006 at 2:21pm
<% 'Dimension variables Dim adoCon 'Holds the Database Connection Object Dim rsUpdateEntry 'Holds the recordset for the record to be updated Dim strSQL 'Holds the SQL query to query the database Dim lngRecordNo 'Holds the record number to be updated
'Read in the record number to be updated lngRecordNo = CLng(Request.Form("IDNum"))
'Create an ADO connection object Set adoCon = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection adoCon.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("tester.mdb")
'Create an ADO recordset object Set rsUpdateEntry = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database strSQL = "SELECT tblNames.* FROM tblNames WHERE IDNum=" & lngRecordNo
'Set the cursor type we are using so we can navigate through the recordset
rsUpdateEntry.CursorType = 3 rsUpdateEntry.locktype = 3
'Open the recordset with the SQL query rsUpdateEntry.Open strSQL, adoCon
'Update the record in the recordset rsUpdateEntry.Fields("Name") = Request.Form("name") rsUpdateEntry.Fields("Surname") = Request.Form("surname")
'Write the updated recordset to the database rsUpdateEntry.Update
'Reset server objects rsUpdateEntry.Close Set rsUpdateEntry = Nothing Set adoCon = Nothing
'Return to the update select page in case another record needs deleting Response.Redirect "update_select.asp" %>
|
-------------
|
Posted By: BlackGoldFish
Date Posted: 20 March 2006 at 1:20pm
|
Excellent that worked, thanks a lot.
|
|