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