|
 |
access_asp thread: Chap14 in Beginner ASP 3.0 (AddNew.asp)
Message #1 by "Truong Dinh Vu" <vudtruong@y...> on Tue, 5 Nov 2002 03:37:10
|
|
I HAVE ERROR MESSAGE LIKE THIS:
Error Type:
Microsoft JET Database Engine (0x80040E09)
Cannot update. Database or object is read-only.
/BegASP/AddNew.asp, line 21
MY CODE IS:
<%
Option Explicit
Dim strConnect
%>
<!-- #include file="DataStore.asp" -->
<!-- METADATA TYPE="typelib"
FILE="C:\Program Files\Common
Files\System\ado\msado15.dll" -->
<HTML>
<HEAD>
<TITLE>Adding a New Record</TITLE>
</HEAD>
<BODY>
<%
Dim objRS, intIDForNewRecord
Set objRS = Server.CreateObject ("ADODB.Recordset")
objRS.Open "Movies", strConnect, adOpenStatic, adLockOptimistic,
adCmdTable
objRS.MoveLast
intIDForNewRecord = objRS("MovieID") + 1
objRS.AddNew ' add a new record
objRS("MovieID") = intIDForNewRecord
objRS("Title") = "Psycho"
objRS.Update
objRS.Close
objRS.Open "SELECT * FROM Movies WHERE MovieID=" & intIDForNewRecord, _
strConnect, adOpenForwardOnly, adLockReadOnly,
adCmdText
If objRS.EOF Then
Response.Write "New record not found - something went wrong"
Else
Response.Write "You've successfully added a new record:<BR> " & _
"Movie title = '" & objRS("Title") & "'<BR>" & _
"MovieID = " & objRS("MovieID")
End If
objRS.Close ' now close and clean up
Set objRS = Nothing
%>
</BODY>
</HTML>
DATASTORES.ASP IS:
<%
Dim strDatabaseType
'Choose one of the following two lines, and comment out the other
strDatabaseType = "Access"
'strDatabaseType = "MSDE"
'Now we use this selection to specify the connection string
If strDatabaseType = "Access" Then
strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\datastores\Movie2000.mdb;" &
_
"Persist Security Info=False"
Else
strConnect = "Provider=SQLOLEDB;Persist Security Info=False;" & _
"User ID=sa;Initial Catalog=Movie;" & _
"Initial File Name=C:\MSSQL7\Data\Movie2000.mdf"
End If
%>
PLEASE HELP ME. I ALREADY CHECK FOR THE FOLDER PROPERTY. UNCHECKED AT
READ-ONLY. THANK YOU.
TRUONG
Message #2 by "Ken Schaefer" <ken@a...> on Tue, 5 Nov 2002 15:19:25 +1100
|
|
Hi,
You need to change the *NTFS* properties for the folder in question. Give
Everyone "Change" (RWXD) permissions, and see if that fixes the problem.
Also, the code below is pretty horrible...
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Truong Dinh Vu" <vudtruong@y...>
Subject: [access_asp] Chap14 in Beginner ASP 3.0 (AddNew.asp)
: I HAVE ERROR MESSAGE LIKE THIS:
: Error Type:
: Microsoft JET Database Engine (0x80040E09)
: Cannot update. Database or object is read-only.
: /BegASP/AddNew.asp, line 21
:
: MY CODE IS:
: <%
: Option Explicit
: Dim strConnect
: %>
: <!-- #include file="DataStore.asp" -->
: <!-- METADATA TYPE="typelib"
: FILE="C:\Program Files\Common
: Files\System\ado\msado15.dll" -->
: <HTML>
: <HEAD>
: <TITLE>Adding a New Record</TITLE>
: </HEAD>
: <BODY>
: <%
: Dim objRS, intIDForNewRecord
: Set objRS = Server.CreateObject ("ADODB.Recordset")
: objRS.Open "Movies", strConnect, adOpenStatic, adLockOptimistic,
: adCmdTable
:
: objRS.MoveLast
: intIDForNewRecord = objRS("MovieID") + 1
:
: objRS.AddNew ' add a new record
: objRS("MovieID") = intIDForNewRecord
: objRS("Title") = "Psycho"
: objRS.Update
: objRS.Close
:
: objRS.Open "SELECT * FROM Movies WHERE MovieID=" & intIDForNewRecord, _
: strConnect, adOpenForwardOnly, adLockReadOnly,
: adCmdText
: If objRS.EOF Then
: Response.Write "New record not found - something went wrong"
: Else
: Response.Write "You've successfully added a new record:<BR> " & _
: "Movie title = '" & objRS("Title") & "'<BR>" & _
: "MovieID = " & objRS("MovieID")
: End If
:
: objRS.Close ' now close and clean up
: Set objRS = Nothing
: %>
: </BODY>
: </HTML>
:
: DATASTORES.ASP IS:
: <%
: Dim strDatabaseType
:
: 'Choose one of the following two lines, and comment out the other
: strDatabaseType = "Access"
: 'strDatabaseType = "MSDE"
:
: 'Now we use this selection to specify the connection string
: If strDatabaseType = "Access" Then
: strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
: "Data Source=C:\datastores\Movie2000.mdb;" &
: _
: "Persist Security Info=False"
: Else
: strConnect = "Provider=SQLOLEDB;Persist Security Info=False;" & _
: "User ID=sa;Initial Catalog=Movie;" & _
: "Initial File Name=C:\MSSQL7\Data\Movie2000.mdf"
: End If
: %>
:
: PLEASE HELP ME. I ALREADY CHECK FOR THE FOLDER PROPERTY. UNCHECKED AT
: READ-ONLY. THANK YOU.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
 |