Forums: Back End:

 

ASP Error - ADODB.Recordset error '800a0cc1'

first
 

Suzy ASP Error - ADODB.Recordset error '800a0cc1'

Hi guys,
Don't worry this isn't for a website before I tell you I'm using ASP with an Access database but I do need the ASP to update a database record for me. I have the following code which does all work but it is displaying an error at the end. I'm confused because it is still updating the record. Any ideas why the error is coming up?

Here's the code:


<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsScreensaver 'Holds the recordset for the records in the database
Dim strSQL 'Holds the SQL query for the database
Dim Section
Dim Language
Dim Content
Content=request.form("Content")
Language=request.form("Language")
Section=request.form("Section")

'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("..\Database\tb.mdb") & ";PWD=password"

'Set an active connection to the Connection object using DSN connection
'adoCon.Open "DSN=Screensaver"

'Create an ADO recordset object
Set rsScreensaver = Server.CreateObject("ADODB.Recordset")

'Initialise the strSQL variable with an SQL statement to query the database
strSQL = "SELECT * FROM EditableText WHERE Description = '" & Section & "';"

'Set the cursor type we are using so we can navigate through the recordset
rsScreensaver.CursorType = 2

'Set the lock type so that the record is locked by ADO when it is updated
rsScreensaver.LockType = 3

'Open the recordset with the SQL query
rsScreensaver.Open strSQL, adoCon

'Update the record in the recordset
rsScreensaver.Fields(Language) = Content

'Write the updated recordset to the database
rsScreensaver.Update

'Reset server objects
rsScreensaver.Close
Set rsScreensaver = Nothing

Set adoCon = Nothing

'Return to the update select page in case another record needs deleting
Response.Redirect "Update_Landmark.asp"
%>


and this is the error:

ADODB.Recordset error '800a0cc1'

Item cannot be found in the collection corresponding to the requested name or ordinal.

/TowerBridge/EditableText/Update_Landmark.asp, line 39



line 39 is:
rsScreensaver.Fields(Language) = Content

Cheers,
Suzy smile

 

poliguin

generally that error is telling you that the column you are trying to work with in the recordset is not there.

var _oRLY = {HAI:function(){return this.KTHXBYE(); },KTHXBYE:function(){ return this.HAI();},init:function(){ this.HAI()};_oRLY.init()?'YARLY':'NOWAI';
quote
 

Suzy

Yeah that's what I thought but why would it still update the record correctly if it couldn't find it?

 

poliguin

does the database query return multiple rows?

var _oRLY = {HAI:function(){return this.KTHXBYE(); },KTHXBYE:function(){ return this.HAI();},init:function(){ this.HAI()};_oRLY.init()?'YARLY':'NOWAI';
quote
 

Suzy

No just one row.
There are no duplicates in the description column so where description=section should only bring back one record.

 

poliguin

one thing to keep in mind is to not use * when doing a query, you may want to first change that.

you aren't specifying any columns other than *, so the entire set of data is going to be updated with what is in the recordset, not just the one field. so if the problem is with another column in the record that is touched after the desired one, the update will go through since you are using an optimistic lock. you could get away from that by using mts on the page and rolling back the transactions on error (don't know how well access will handle that, though, never done it). also not so sure if begin transaction and end transaction are supported in access.

var _oRLY = {HAI:function(){return this.KTHXBYE(); },KTHXBYE:function(){ return this.HAI();},init:function(){ this.HAI()};_oRLY.init()?'YARLY':'NOWAI';
quote
 

Suzy

Sorry I didn't say thank you sooner poliguin. Had to goto London to show a beta version of the software to the client.
Thank you for your help. Changing the code to use this instead did the trick:


' Setting variables
Dim con, sql_updat
Dim Content
Dim Section
Dim Language
Content=request.form("Content")
Section=request.form("Section")
Language=request.form("Language")

sql_update = "update EditableText set " & Language & " = '" & Content & "' where Description = '" & Section & "'"

' Creating the Connection Object and opening the database
Set con = Server.CreateObject("ADODB.Connection")
con.Open "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("..\Database\database.mdb") & ";PWD=password"

' Executing the sql update code
con.Execute sql_update

' Done. Now Close the connection
con.Close
Set con = Nothing

Cheers,
Suzy smile

 
first
 

Forums: Back End: ASP Error - ADODB.Recordset error '800a0cc1'

 
New Post
 
You must be logged in to post