|
 |
access_asp thread: Database or Object is Read-Only. Cannot Update
Message #1 by MLumunsad@h... on Wed, 11 Sep 2002 11:22:29 -0700
|
|
Hi everyone. Well, after one stumbling block, I have run into another. I
am trying to update the "Trim Level" table in my database. However, when
the server tries to update the table i get this error.
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Cannot update. Database or object
is read-only.
/add_new_trim_level.asp, line 533
However, I can update all the other tables that are in this database. I
don't understand how this one particular table can be giving me so much
problems. The asp coding is the same as all the other asp files.
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsAddTrim 'Holds the recordset for the new record to be added
Dim strSQL 'Holds the SQL query to query the database
Dim intNewID3
'Create an ADO connection object
Set adoCon = Server.CreateObject ("ADODB.Connection")
'Set an active connection to the Connection object using DSN connection
adoCon.Open "DSN=unify"
Set rsAddTrim = Server.CreateObject("ADODB.Recordset")
' Create the query to extract records
strSQL = "SELECT [Trim Level].[PK#Trim], [Trim Level].[FK#Model], [Trim
Level].Bodystyle, [Trim Level].Description, [Trim Level].[Accel Time],
[Trim Level].QuarterMile, [Trim Level].[Braking 0-60], [Trim Level].[EPA
mpg], [Trim Level].Transmission, [Trim Level].[#Gears], [Trim
Level].[Engine Config], [Trim Level].[Drivetrain Layout] FROM (((Make INNER
JOIN Model ON Make.[PK#Make]=Model.[FK#Make]) INNER JOIN Rumor ON
Model.[PK#Model]=Rumor.[FK#Model]) INNER JOIN [Trim Level] ON
Model.[PK#Model]=[Trim Level].[FK#Model]) INNER JOIN [Engine Code] ON [Trim
Level].[PK#Trim]=[Engine Code].[FK#Trim];"
rsAddTrim.CursorType = 1
rsAddTrim.LockType = 3
intNewID3 = Request.QueryString("intRumorID")
rsAddTrim.Open strSQL , adoCon
rsAddTrim.AddNew
rsAddTrim.Fields("FK#Model") = Request.Form("FK_Num_Model")
rsAddTrim.Fields("BodyStyle") = Request.Form("BodyStyle")
rsAddTrim.Fields("Description") = Request.Form("Description")
rsAddTrim.Fields("Accel Time") = Request.Form("AccelTime")
rsAddTrim.Fields("QuarterMile") = Request.Form("QuarterMile")
rsAddTrim.Fields("Braking 0-60") = Request.Form("Braking")
rsAddTrim.Fields("EPA mpg") = Request.Form("EPA")
rsAddTrim.Fields("Transmission") = Request.Form("Transmission")
rsAddTrim.Fields("#Gears") = Request.Form("NumGears")
rsAddTrim.Fields("Engine Config") = Request.Form("EngConfig")
rsAddTrim.Fields("Drivetrain Layout") = Request.Form("Drivetrain")
rsAddTrim.Update
intRumorID = rsAddTrim.Fields.Item("PK#Trim").Value
rsAddTrim.Close
'Reset server objects
Set rsAddTrim = Nothing
Set adoCon = Nothing
Response.Redirect ("add_new_engine.asp?intEngineID=") & intEngineID
%>
<% END If %>
Message #2 by "Ken Schaefer" <ken@a...> on Thu, 12 Sep 2002 12:11:03 +1000
|
|
You must think I'm stupid or something...
Don't you remember that I said (in response to a problem you were having
only a few days ago):
a) Don't use magic numbers in your code
b) Don't use recordsets to insert data into your database, use SQL
statements instead
c) Don't use field names in your database that contain characters like #
etc
If you follow the advice you are given, you will have far less problems that
you are having.
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: <MLumunsad@h...>
Subject: [access_asp] Database or Object is Read-Only. Cannot Update
: Hi everyone. Well, after one stumbling block, I have run into another. I
: am trying to update the "Trim Level" table in my database. However, when
: the server tries to update the table i get this error.
:
: Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
: [Microsoft][ODBC Microsoft Access Driver] Cannot update. Database or
object
: is read-only.
: /add_new_trim_level.asp, line 533
Message #3 by "Michael Lumunsad" <mlumunsad@h...> on Thu, 12 Sep 2002 17:36:30
|
|
Ken...I never said you were stupid or anything. However, I did not change
the code because it worked on the 4 other tables that are in this
database. The prior problem I had was independent of this problem because
that problem was saving and passing the autonumber ID to another asp
page. That was solved.
And I have tested your "do not use the magic numbers" in my code. But
when I don't use the magic numbers, I run into many more problems, such as
having none of the tables being able to be updated. Therefore, why change
something that actually works?
Well, thank you for your help, but I see my inexperience just annoys you.
> You must think I'm stupid or something...
Don't you remember that I said (in response to a problem you were having
only a few days ago):
a) Don't use magic numbers in your code
b) Don't use recordsets to insert data into your database, use SQL
statements instead
c) Don't use field names in your database that contain characters like #
etc
If you follow the advice you are given, you will have far less problems
that
you are having.
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: <MLumunsad@h...>
Subject: [access_asp] Database or Object is Read-Only. Cannot Update
: Hi everyone. Well, after one stumbling block, I have run into another.
I
: am trying to update the "Trim Level" table in my database. However,
when
: the server tries to update the table i get this error.
:
: Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
: [Microsoft][ODBC Microsoft Access Driver] Cannot update. Database or
object
: is read-only.
: /add_new_trim_level.asp, line 533
Message #4 by "Rob Parkhouse" <rparkhouse@o...> on Fri, 13 Sep 2002 01:48:37
|
|
> Hi everyone. Well, after one stumbling block, I have run into another.
I
am trying to update the "Trim Level" table in my database. However, when
the server tries to update the table i get this error.
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Cannot update. Database or object
is read-only.
/add_new_trim_level.asp, line 533
However, I can update all the other tables that are in this database. I
don't understand how this one particular table can be giving me so much
problems. The asp coding is the same as all the other asp files.
<%
'Dimension variables
Dim adoCon 'Holds the Database Connection Object
Dim rsAddTrim 'Holds the recordset for the new record to be added
Dim strSQL 'Holds the SQL query to query the database
Dim intNewID3
'Create an ADO connection object
Set adoCon = Server.CreateObject ("ADODB.Connection")
'Set an active connection to the Connection object using DSN connection
adoCon.Open "DSN=unify"
Set rsAddTrim = Server.CreateObject("ADODB.Recordset")
' Create the query to extract records
strSQL = "SELECT [Trim Level].[PK#Trim], [Trim Level].[FK#Model], [Trim
Level].Bodystyle, [Trim Level].Description, [Trim Level].[Accel Time],
[Trim Level].QuarterMile, [Trim Level].[Braking 0-60], [Trim Level].[EPA
mpg], [Trim Level].Transmission, [Trim Level].[#Gears], [Trim
Level].[Engine Config], [Trim Level].[Drivetrain Layout] FROM (((Make INNER
JOIN Model ON Make.[PK#Make]=Model.[FK#Make]) INNER JOIN Rumor ON
Model.[PK#Model]=Rumor.[FK#Model]) INNER JOIN [Trim Level] ON
Model.[PK#Model]=[Trim Level].[FK#Model]) INNER JOIN [Engine Code] ON [Trim
Level].[PK#Trim]=[Engine Code].[FK#Trim];"
rsAddTrim.CursorType = 1
rsAddTrim.LockType = 3
intNewID3 = Request.QueryString("intRumorID")
rsAddTrim.Open strSQL , adoCon
rsAddTrim.AddNew
rsAddTrim.Fields("FK#Model") = Request.Form("FK_Num_Model")
rsAddTrim.Fields("BodyStyle") = Request.Form("BodyStyle")
rsAddTrim.Fields("Description") = Request.Form("Description")
rsAddTrim.Fields("Accel Time") = Request.Form("AccelTime")
rsAddTrim.Fields("QuarterMile") = Request.Form("QuarterMile")
rsAddTrim.Fields("Braking 0-60") = Request.Form("Braking")
rsAddTrim.Fields("EPA mpg") = Request.Form("EPA")
rsAddTrim.Fields("Transmission") = Request.Form("Transmission")
rsAddTrim.Fields("#Gears") = Request.Form("NumGears")
rsAddTrim.Fields("Engine Config") = Request.Form("EngConfig")
rsAddTrim.Fields("Drivetrain Layout") = Request.Form("Drivetrain")
rsAddTrim.Update
intRumorID = rsAddTrim.Fields.Item("PK#Trim").Value
rsAddTrim.Close
'Reset server objects
Set rsAddTrim = Nothing
Set adoCon = Nothing
Response.Redirect ("add_new_engine.asp?intEngineID=") & intEngineID
%>
<% END If %>
I have only glanced at you code but:
1. You are not simply trying to update a single table, but a multiple
table query. Perhaps the query turns out to be "non updatable". Set up a
similar query in Access, view it in datasheet view and try to update a
row. If you can't then that is the problem. Maybe you have to update each
table separately in the ASP.
Good luck
Rob
Message #5 by "Ken Schaefer" <ken@a...> on Fri, 13 Sep 2002 11:30:29 +1000
|
|
Michael,
I realise that you're struggling with a problem, otherwise you wouldn't be
asking for help here. But saying "why should I change something that works?"
is not helpful. I'm not going to copy out large slabs of reference material
that can be found in practically every programming text there is to justify
why you shouldn't use "magic numbers" for example.
Pick up a book like: "Code Complete" by Steve McConnell:
http://www.amazon.com/exec/obidos/ASIN/1556154844/
if you want lots of good programming practice (and explanations).
I also said "Use an SQL statement to insert/update/delete data" - don't use
recordsets. Recordsets are for retrieving data. If you'd try to write an SQL
statement to update this recordset I think you would have seen what the
problem was (namely that you'd be struggling to write something that would
actually work).
If you are having problems following my advice, I'm more than willing to
help you out so that you can get it working.
Cheers
Ken
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Michael Lumunsad" <mlumunsad@h...>
Subject: [access_asp] Re: Database or Object is Read-Only. Cannot Update
: Ken...I never said you were stupid or anything. However, I did not change
: the code because it worked on the 4 other tables that are in this
: database. The prior problem I had was independent of this problem because
: that problem was saving and passing the autonumber ID to another asp
: page. That was solved.
:
: And I have tested your "do not use the magic numbers" in my code. But
: when I don't use the magic numbers, I run into many more problems, such as
: having none of the tables being able to be updated. Therefore, why change
: something that actually works?
:
: Well, thank you for your help, but I see my inexperience just annoys you.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Message #6 by "Michael Lumunsad" <mlumunsad@h...> on Fri, 13 Sep 2002 17:52:45
|
|
Rob thanks for your help. I knew it had to be something with the actual
database and not my ASP. I'll review the design and get back to you.
Thanks again.
> > Hi everyone. Well, after one stumbling block, I have run into
another.
I>
a> m trying to update the "Trim Level" table in my database. However,
when
t> he server tries to update the table i get this error.
> Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[> Microsoft][ODBC Microsoft Access Driver] Cannot update. Database or
object
i> s read-only.
/> add_new_trim_level.asp, line 533
> However, I can update all the other tables that are in this database. I
d> on't understand how this one particular table can be giving me so much
p> roblems. The asp coding is the same as all the other asp files.
> <%
'> Dimension variables
D> im adoCon 'Holds the Database Connection Object
D> im rsAddTrim 'Holds the recordset for the new record to be added
D> im strSQL 'Holds the SQL query to query the database
D> im intNewID3
> 'Create an ADO connection object
S> et adoCon = Server.CreateObject ("ADODB.Connection")
> 'Set an active connection to the Connection object using DSN connection
a> doCon.Open "DSN=unify"
> Set rsAddTrim = Server.CreateObject("ADODB.Recordset")
> ' Create the query to extract records
> strSQL = "SELECT [Trim Level].[PK#Trim], [Trim Level].[FK#Model], [Trim
L> evel].Bodystyle, [Trim Level].Description, [Trim Level].[Accel Time],
[> Trim Level].QuarterMile, [Trim Level].[Braking 0-60], [Trim Level].[EPA
m> pg], [Trim Level].Transmission, [Trim Level].[#Gears], [Trim
L> evel].[Engine Config], [Trim Level].[Drivetrain Layout] FROM (((Make
INNER
J> OIN Model ON Make.[PK#Make]=Model.[FK#Make]) INNER JOIN Rumor ON
M> odel.[PK#Model]=Rumor.[FK#Model]) INNER JOIN [Trim Level] ON
M> odel.[PK#Model]=[Trim Level].[FK#Model]) INNER JOIN [Engine Code] ON
[Trim
L> evel].[PK#Trim]=[Engine Code].[FK#Trim];"
> rsAddTrim.CursorType = 1
> rsAddTrim.LockType = 3
> intNewID3 = Request.QueryString("intRumorID")
> rsAddTrim.Open strSQL , adoCon
> rsAddTrim.AddNew
> rsAddTrim.Fields("FK#Model") = Request.Form("FK_Num_Model")
> rsAddTrim.Fields("BodyStyle") = Request.Form("BodyStyle")
> rsAddTrim.Fields("Description") = Request.Form("Description")
> rsAddTrim.Fields("Accel Time") = Request.Form("AccelTime")
> rsAddTrim.Fields("QuarterMile") = Request.Form("QuarterMile")
> rsAddTrim.Fields("Braking 0-60") = Request.Form("Braking")
> rsAddTrim.Fields("EPA mpg") = Request.Form("EPA")
> rsAddTrim.Fields("Transmission") = Request.Form("Transmission")
> rsAddTrim.Fields("#Gears") = Request.Form("NumGears")
> rsAddTrim.Fields("Engine Config") = Request.Form("EngConfig")
> rsAddTrim.Fields("Drivetrain Layout") = Request.Form("Drivetrain")
> rsAddTrim.Update
> intRumorID = rsAddTrim.Fields.Item("PK#Trim").Value
> rsAddTrim.Close
> 'Reset server objects
> Set rsAddTrim = Nothing
> Set adoCon = Nothing
> Response.Redirect ("add_new_engine.asp?intEngineID=") & intEngineID
>
%> >
> <% END If %>
>
I> have only glanced at you code but:
> 1. You are not simply trying to update a single table, but a multiple
t> able query. Perhaps the query turns out to be "non updatable". Set up a
s> imilar query in Access, view it in datasheet view and try to update a
r> ow. If you can't then that is the problem. Maybe you have to update
each
t> able separately in the ASP.
> Good luck
> Rob
|
|
 |