Problem med att lägga til poster i databas

ASP

4 svar · 219 visningar · startad av His Divine Shadow

Medlem sedan sep. 20004 079 inlägg
Trådstart#1

När jag ska lägga till en post i en databas får jag detta meddelande:

Error Type:
Microsoft JET Database Engine (0x80040E09)
Cannot update. Database or object is read-only.
/addst.asp, line 137

Linje 137 är:

'Use the addnew method of the recordset object to add a record
137 -> rs.addnew
'Set the table column = to my input text box from my form
rs("Author") = Request.Form("Author") 
.....
Medlem sedan dec. 200012 464 inlägg
#2

Hur ser koden där du skapar recordsetet ut?

Medlem sedan sep. 20004 079 inlägg
#3

'Declare all local variables
dim conn
dim rs
dim strID
dim strconn

'set a local variable to my DSN-less connection String
strconn = "PROVIDER=MICROSOFT.JET.OLEDB.4.0;DATA SOURCE=G:\inetpub\wwwroot\db\quotes.mdb;"

'Create the Connection object
set conn = server.createobject("adodb.connection")
conn.open strconn

'Create the recordset object
set rs = server.createobject("adodb.recordset")
'This statement opens the table so we can add a record notice the addnew
'The 2, 2 is how the table is opened there are many ways it can be opened
rs.open "Quotes", conn, 2, 2

'Use the addnew method of the recordset object to add a record
rs.addnew
'Set the table column = to my input text box from my form
rs("Author") = Request.Form("Author")
rs("Email") = Request.Form("Email")
rs("Category") = Request.Form("Category")
rs("Subcategory") = Request.Form("Subcategory")
rs("Type") = Request.Form("Type")
rs("Quote") = Request.Form("Quote")
rs.update

'Always! Always set your objects to nothing. This clears them out of servers memory
'Your network admins will like this
%>

Medlem sedan dec. 200012 464 inlägg
#4

Har du skrivrättigheter på databasfilerna?

Medlem sedan sep. 20004 079 inlägg
#5

Hmmm... Lite nytt dethär XP och IIS5.
Men jag kollade runt lite och satte "write" rättigheter för alla, nu funkar det...

Konstigt nog behövdes aldrig detta i NT4 som jag suttit med tils nyligen...

376 ms totalt · 4 externa anrop · v20260731065814-full.d34c6d5a
123 ms — deklarationer (db)
126 ms — hämta statistik (db)
123 ms — hämta tråd, inlägg och bilagor (db)
120 ms — ändringar (db)