Solved

Edit page just started barking out an error.

Posted on 2004-04-06
4
311 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
An enjoyable and seamless user experience can go a long way on an eCommerce site. While a cohesive layout and engaging copy play roles in creating a positive user experience, some sites neglect aspects that seem marginal but in actuality prove very …
This video teaches users how to migrate an existing Wordpress website to a new domain.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

831 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