webForumDet fria alternativet

Problem med att lägga til poster i databas

ASP

4 svar · 214 visningar · startad av His Divine Shadow

Medlem sedan sep. 20004 079 inlägg
Frågan#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") 
.....

------------------
His Divine Shadow is the most despicable being ever created.(så sade en fan)

Sprit löser inga problem. Men det gör inte mjölk heller.

T-bird 1200; GeForce 256 32MB; WinNT4/XP; 512MB RAM; Dialup

Medlem sedan dec. 200012 464 inlägg
#2

Hur ser koden där du skapar recordsetet ut?

------------------
essentitia preter non sans multiplicandum

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
%>

------------------
His Divine Shadow is the most despicable being ever created.(så sade en fan)

Sprit löser inga problem. Men det gör inte mjölk heller.

T-bird 1200; GeForce 256 32MB; WinNT4/XP; 512MB RAM; Dialup

Medlem sedan dec. 200012 464 inlägg
#4

Har du skrivrättigheter på databasfilerna?

------------------
essentitia preter non sans multiplicandum

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...

------------------
His Divine Shadow is the most despicable being ever created.(så sade en fan)

Sprit löser inga problem. Men det gör inte mjölk heller.

T-bird 1200; GeForce 256 32MB; WinNT4/XP; 512MB RAM; Dialup

267 ms totalt · 4 externa anrop · v20260731065814-full.a51de22e
119 ms — deklarationer (db)
0 ms — hämta statistik (cache)
131 ms — hämta tråd, inlägg och bilagor (db)
134 ms — ändringar (db)