I'm trying to add a record to a table, using VBScript. I haven't had any problems viewing records, but now I'm adding in this capability, and I'm having issues with opening a read/write recordset.
The error I'm getting is this:
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver] Cannot update. Database or object is read-only.
It occurs on the record.Update line in the following code:
You can also see where I tried, unsuccessfully, to change database.Mode after I was reading around on Microsoft "help" pages and thought that might have something to do with it.
Thanks for any ideas you can provide!
The error I'm getting is this:
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver] Cannot update. Database or object is read-only.
It occurs on the record.Update line in the following code:
Code:
<!-- #INCLUDE FILE="adovbs.inc" -->
<%
'...
Sub displayRecord(mode, table, id)
'{'
Dim counter
counter = 1
Dim database 'as connection'
Dim records 'as recordset'
Dim strSQL 'as SQL statement'
Dim nbrFields
Dim fieldName
Set database = Server.CreateObject("ADODB.Connection")
'database.Mode = adModeReadWrite'
database.Open "testdb"
If mode = "addnew" Then
Call addRecord(database, table, id)
'...skip to addRecord ...
Sub addRecord(dbConnection, table, id)
'{'
Dim record 'as recordset'
Set record = Server.CreateObject("ADODB.Recordset")
record.Open table, dbConnection, adOpenDynamic, adLockOptimistic
record.AddNew
record("Name") = "test"
id = record("ID")
record.Update
record.Close
Set record = Nothing
'}'
End Sub
You can also see where I tried, unsuccessfully, to change database.Mode after I was reading around on Microsoft "help" pages and thought that might have something to do with it.
Thanks for any ideas you can provide!