Solved

Edit page just started barking out an error.

Posted on 2004-04-06
4
310 Views
Last Modified: 2008-03-04
Hi everyone,
    My edit page was working great up until today. I haven't done anything to it, but now it doesn't want to work.
This is the error I receive after the user tries to update his/her information:


Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.
/test2/edit.asp, line 154


Here is my code:

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>

<html>
<head>
<title>Edit</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<%
' *** Edit Operations: declare variables
Dim adoCon             'Database Connection Variable
Dim strCon            'Holds the Database driver and the path and name of the database
Dim rsCheckUser       'Database Recordset Variable
Dim strAccessDB       'Holds the Access Database Name
Dim strSQL             'Database query sring
Dim strUserName       'Holds the user name
Dim strMemberName

Dim MM_editAction
Dim MM_abortEdit
Dim MM_editQuery
Dim MM_editCmd

Dim MM_editConnection
Dim MM_editTable
Dim MM_editRedirectUrl
Dim MM_editColumn
Dim MM_recordId

Dim MM_fieldsStr
Dim MM_columnsStr
Dim MM_fields
Dim MM_columns
Dim MM_typeArray
Dim MM_formVal
Dim MM_delim
Dim MM_altVal
Dim MM_emptyVal
Dim MM_i
Dim newConn  

'Initalise the strUserName variable
strUserName = Request.form("txtUserName")

strMemberName = Request.QueryString("name")

'Initialise the strAccessDB variable with the name of the Access Database
strAccessDB = "Book"

'Create a connection odject
Set adoCon = Server.CreateObject("ADODB.Connection")
                  
'Database connection info and driver
strCon = "DRIVER={Microsoft Access Driver (*.mdb)};uid=;pwd=; DBQ=" & Server.MapPath(strAccessDB)

'Set an active connection to the Connection object
adoCon.Open strCon

'Create a recordset object
Set rsCheckUser = Server.CreateObject("ADODB.Recordset")

strSQL = "SELECT MemberID, Address, City, Province, PostalCode, WorkPhone, Extension, HomePhone, Fax, Email, Email2  FROM MEMBER2 where memberid ='" & strMemberName & "'"
rsCheckUser.Open  strSQL, strCon

 MM_editAction = CStr(Request.ServerVariables("SCRIPT_NAME"))
 If (Request.QueryString <> "") Then
'  MM_editAction = MM_editAction & "?" & Request.QueryString("name")
  MM_editAction = MM_editAction & "?" & strMemberName

 End If

' boolean to abort record edit
 MM_abortEdit = false

' query string to execute
 MM_editQuery = ""


' *** Update Record: set variables

 If (CStr(Request("MM_update")) = "form1" And CStr(Request("MM_recordId")) <> "") Then

  MM_editConnection = MM_Data_STRING
  MM_editTable = "MEMBER2"
  MM_editColumn = "MemberId"
  MM_recordId = "" + Request.Form("MM_recordId") + ""
  MM_editRedirectUrl = "Password.asp"
  MM_fieldsStr  = "Address|value|City|value|Province|value|PostalCode|value|WorkPhone|value|Extension|value|HomePhone|value|Fax|value|Email|value|Email2|value"
  MM_columnsStr = "Address|',none,''|City|',none,''|Province|',none,''|PostalCode|',none,''|WorkPhone|',none,''|Extension|',none,''|HomePhone|',none,''|Fax|',none,''|Email|',none,''|Email2|',none,''"

  ' create the MM_fields and MM_columns arrays
  MM_fields = Split(MM_fieldsStr, "|")
  MM_columns = Split(MM_columnsStr, "|")
 
  ' set the form values
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_fields(MM_i+1) = CStr(Request.Form(MM_fields(MM_i)))
  Next

  ' append the query string to the redirect URL
 If (MM_editRedirectUrl <> "" And Request.QueryString("name") <> "") Then
    If (InStr(1, MM_editRedirectUrl, "?", vbTextCompare) = 0 And Request.QueryString("name") <> "") Then
      MM_editRedirectUrl = MM_editRedirectUrl & "?" & Request.QueryString("name")
    Else
      MM_editRedirectUrl = MM_editRedirectUrl & "&" & Request.QueryString("name")
    End If
  End If

 End If


' *** Update Record: construct a sql update statement and execute it

 If (CStr(Request("MM_update")) <> "" And CStr(Request("MM_recordId")) <> "") Then

  ' create the sql update statement
  MM_editQuery = "update " & MM_editTable & " set "
  For MM_i = LBound(MM_fields) To UBound(MM_fields) Step 2
    MM_formVal = MM_fields(MM_i+1)
    MM_typeArray = Split(MM_columns(MM_i+1),",")
    MM_delim = MM_typeArray(0)
    If (MM_delim = "none") Then MM_delim = ""
    MM_altVal = MM_typeArray(1)
    If (MM_altVal = "none") Then MM_altVal = ""
    MM_emptyVal = MM_typeArray(2)
    If (MM_emptyVal = "none") Then MM_emptyVal = ""
    If (MM_formVal = "") Then
    MM_formVal = MM_emptyVal
    Else
      If (MM_altVal <> "") Then
        MM_formVal = MM_altVal
      ElseIf (MM_delim = "'") Then  ' escape quotes
        MM_formVal = "'" & Replace(MM_formVal,"'","''") & "'"
      Else
        MM_formVal = MM_delim + MM_formVal + MM_delim
      End If
    End If
    If (MM_i <> LBound(MM_fields)) Then
      MM_editQuery = MM_editQuery & ","
    End If
   MM_editQuery = MM_editQuery & MM_columns(MM_i) & " = " & MM_formVal
  Next
   MM_editQuery = MM_editQuery & " where " & MM_editColumn & " = '" & MM_recordId & "'"

  If (Not MM_abortEdit) Then
    ' execute the update
 ' set newConn = Server.CreateObject("ADODB.Connection")
 ' newConn.Open MM_editConnection
 ' MM_editCmd.ActiveConnection = newConn

    Set MM_editCmd = Server.CreateObject("ADODB.Command")
    MM_editCmd.ActiveConnection = adoCon
    MM_editCmd.CommandText = MM_editQuery
    MM_editCmd.Execute
    MM_editCmd.ActiveConnection.Close

    If (MM_editRedirectUrl <> "") Then
      Response.Redirect(MM_editRedirectUrl)
    End If
  End If
 End If

 %>




<% If Not rsCheckUser.EOF or Not rsCheckUser.BOF Then %>
<form method="post" action="<%=MM_editAction%>" name="form1">
<caption><strong>Please Update the Following Information:</strong></caption>
  <table align="center">
 
   
    <tr valign="baseline">
      <td nowrap align="right">Address:</td>
      <td> <input type="text" name="Address" value="<%=trim(rsCheckUser.Fields.Item("Address").Value)%>"size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">City:</td>
      <td> <input type="text" name="City" value="<%=trim(rsCheckUser.Fields.Item("City").Value)%>"size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Province:</td>
      <td> <input type="text" name="Province" value="<%=trim(rsCheckUser.Fields.Item("Province").Value)%>"size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">PostalCode:</td>
      <td> <input type="text" name="PostalCode" value="<%=trim(rsCheckUser.Fields.Item("PostalCode").Value)%>"size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">WorkPhone:</td>
      <td> <input type="text" name="WorkPhone" value="<%=trim(rsCheckUser.Fields.Item("WorkPhone").Value)%>"size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Extension:</td>
      <td> <input type="text" name="Extension" value="<%=trim(rsCheckUser.Fields.Item("Extension").Value)%>"size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">HomePhone:</td>
      <td> <input type="text" name="HomePhone" value="<%=trim(rsCheckUser.Fields.Item("HomePhone").Value)%>"size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Fax:</td>
      <td> <input type="text" name="Fax" value="<%=trim(rsCheckUser.Fields.Item("Fax").Value)%>"size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Email:</td>
      <td> <input type="text" name="Email" value="<%=trim(rsCheckUser.Fields.Item("Email").Value)%>"size="32">
      </td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Email2:</td>
      <td> <input type="text" name="Email2" value="<%=trim(rsCheckUser.Fields.Item("Email2").Value)%>"size="32">
      </td>
    </tr>
   
    <tr valign="baseline">
      <td nowrap align="right">&nbsp;</td>
      <td> <input type="submit" value="Save Changes">
        <input name="Input" type="button" value="Next"> </td>
      <td>&nbsp; </td>
    </tr>
  </table>
   <input type="hidden" name="MM_update" value="form1">
  <input type="hidden" name="MM_recordId" value="<%= rsCheckUser.Fields.Item("MemberID").Value %>">
</form>
<% End IF %>
<p>&nbsp;</p>



</body>
</html>
 <%
 rsCheckUser.Close()
 Set rsCheckUser = Nothing
 %>
0
Comment
Question by:Leoncur
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:pepsichris
ID: 10765061
That's normally down to a permissions error on the mdb file - check it's set properly.
0
 

Author Comment

by:Leoncur
ID: 10765408
Hi
 I checked the mdb file and it seems to be fine
0
 
LVL 9

Accepted Solution

by:
pepsichris earned 400 total points
ID: 10765684
Just test it by giving all access to all users as a test and seeing if that works.  The permissions need to be set on the whole folder that the mdb is in (not just the mdb itself) due to the temp files that are created by Access, incidentally.
0
 

Author Comment

by:Leoncur
ID: 10765835
Thank you very much.... I changed permissions to the everyone group and it is working again.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now