Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_web_howto thread: Updating Access DB with ASP


Message #1 by "Chris Thompson" <cthompson@n...> on Wed, 8 May 2002 12:43:15 -0600
I am getting an error when I try to update an Access table.

My code works until I get to the conn.execute SQL statement near the
bottom of my code.  I have checked the path and Access file and NONE are
set to ReadOnly.  Any help would be greatly appreciated.  It is an
Access 2000 file.  I can go to the file directly and add records in
Access.  In the response.write line before the conn.execute, I get the
following results:
************************************************************************
****INSERT INTO TMain (TID, TMainCaption) VALUES (7, 'ds')
************************************************************************
****

The data types are all correct in the DB as TID is a long and
TMainCaption is a text data type

Here is the error:
************************************************************************
****
Microsoft JET Database Engine error '80004005'

Operation must use an updateable query.
************************************************************************
****

Here is my code:
************************************************************************
****
	Dim conn, rs, SQL, MaxID
=09
	Set Conn =3D Server.CreateObject("ADODB.Connection")
   	Conn.Open "Provider=3DMicrosoft.Jet.OLEDB.4.0;DATA SOURCE=3D" &
PhysPath
  	Set rs =3D Server.CreateObject("ADODB.RecordSet")

	SQL =3D "SELECT max(TID) as MaxTID FROM TMain"
 	rs.Open sql, Conn, 3, 3

	MaxID =3D 0
	If Not rs.EOF Then
		MaxID =3D MaxID + rs("MaxTID").Value
		MaxID =3D MaxID + 1
    End If
    rs.Close
   
	SQL =3D "INSERT INTO TMain (TID, TMainCaption) VALUES (" & MaxID &
", '" & request("CatName") & "')"
	Response.Write(SQL)
	conn.execute SQL
=09
	set rs =3D Nothing
	Conn.Close
	set Conn =3D Nothing
************************************************************************
****

Thanks,

Chris Thompson

-+-+-+-+-+-+-+-+-+-+-+-
cthompson@n...
xxx-xxx-xxxx
-+-+-+-+-+-+-+-+-+-+-+-

  Return to Index