« Previous Next »

Thread: [Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query

Last post 07-21-2009 3:53 AM by Paul Lynch. 3 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (4 items)

Sort Posts:

  • 07-20-2009, 10:08 PM

    [Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query

    Hi,

    I already granted permission to user and used updateable query but I still encounter this error in default.asp & addvote.asp?save when I tried to add vote, thanks in advance.

     Microsoft JET Database Engine error '80004005'

    Operation must use an updateable query.

    /poll/result.asp, line 31

    Default.asp

    <!--#include file="setup.asp" -->
    <html>
    <head>
    <title>Employee vote system</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <style type="text/css">
    <!--
    td {  font-size: 9pt}
    -->
    </style>
    </head>

    <body bgcolor="#FFFFFF">
    <div align="center"><form name="form1" method="post" action="result.asp" target="result_win">
    <%
    'on error resume next
    dim rs,sql
    set rs=server.createobject("adodb.recordset")
    if request("id")="" then
     sql="select top 1 * from question order by id desc"
    else
     sql="select * from question where id="&request("id")
    end if
    rs.open sql,conn,1,1
    if rs.eof and rs.bof then response.redirect "addvote.asp"
    follow_id=rs("id")
    allow_multiple=rs("allow_multiple")
    if allow_multiple then response.write "<input type=hidden name=itype value=chk>"
    response.write "<input type=hidden name=qid value="&follow_id&">"
    %>

        <table width="180" border="0" cellpadding="3" cellspacing="0">
          <tr>
            <td bgcolor="#00CCFF"><%=rs("question")%></td>
        </tr>
    <%
    rs.close
    sql="select * from answer where follow_id="&cstr(follow_id)
    rs.open sql,conn,1,1
    do while not rs.eof
    %>
        <tr>
            <td bgcolor="#CCFF66">
     <%
    if allow_multiple then
     response.write "<input type='checkbox' name=chk value='"&rs("id")&"'>"&rs("answer")
    else
     response.write "<input type='radio' name='rb' value='"&rs("id")&"'>"&rs("answer")
    end if
    %>
            </td>
        </tr>
    <%
    rs.movenext
    loop
    rs.close

    %>
        <tr>
            <td bgcolor="#996600">
              <div align="center">
    <input type="submit" name="Submit" value="vote" onClick="document.form1.action='result.asp?action=vote';window.open('','result_win','width=450,height=250,scrollbars=yes')">
    <input type="submit" name="Submit2" value="result" onClick="document.form1.action='result.asp?action=result';window.open('','result_win','width=450,height=250,scrollbars=yes')">
              </div>
            </td>
        </tr>
      </table>
    </form>
      <br>
      <br><b>Past vote</b>
      <table width="88%" border="0">
        <tr bgcolor="#00CC00">
          <td width="8%" nowrap>id</td>
          <td width="58%" nowrap>question</td>
          <td width="8%" nowrap>total votes</td>
          <td width="26%" nowrap>date</td>
        </tr>
    <%
    sql="select * from question order by id desc"
    rs.open sql,conn,1,1
    if err then response.write err.description
    if not rs.eof then
    do while not rs.eof
    %>
        <tr bgcolor="#FFDDFF">
          <td width="8%"><%=rs("id")%></td>
          <td width="58%"><a href=<%=request.servervariables("script_name")%>?id=<%=rs("id")%>><%=rs("question")%></a></td>
          <td width="8%"><%=rs("total_votes")%></td>
          <td width="26%"><%=rs("addtime")%></td>
        </tr>
    <%
    rs.movenext
    loop
    else
     response.write "<tr><td colspan=4>not avaiable!</td></tr>"
    end if
    rs.close
    set rs=nothing
    endconnection
    %>
      </table>
      [<a href="addvote.asp">add vote</a>]</div>
      </body>
    </html>

    Vote.asp
    <!--#include file="setup.asp" -->
    document.write("<form name=agilent method=post action='<%=vote_location%>?action=vote' target=result_win>");
    <%
    'on error resume next
    dim rs,sql
    set rs=server.createobject("adodb.recordset")
    if request("id")="" then
     sql="select top 1 * from question order by id desc"
    else
     sql="select * from question where id="&request("id")
    end if
    rs.open sql,conn,1,1
    total_votes=rs("total_votes")
    follow_id=rs("id")
    allow_multiple=rs("allow_multiple")
    if allow_multiple then response.write "document.write('<input type=hidden name=itype value=chk>');"
    response.write "document.write('<input type=hidden name=qid value="&follow_id&">');"
    %>
    document.write('<table width="100%" border="0" cellpadding="3" cellspacing="0">');
    document.write('<tr><td><%=rs("question")%></td></tr>');
    <%
    rs.close
    sql="select * from answer where follow_id="&cstr(follow_id)
    rs.open sql,conn,1,1
    do while not rs.eof
    %>
     document.write('<tr><td>');
     <%
    if allow_multiple then
     response.write "document.write("&chr(34)&"<input type='checkbox' name='chk' value='"&rs("id")&"'>"&rs("answer")&chr(34)&");"
    else
     response.write "document.write("&chr(34)&"<input type='radio' name='rb' value='"&rs("id")&"'>"&rs("answer")&chr(34)&");"
    end if
    %>
    document.write("</td></tr>");
    <%
    rs.movenext
    loop
    rs.close
    set rs=nothing
    endconnection
    %>
    document.write('<tr><td>Total<b><%=total_votes%></b>employee vote<br>
       <input type="submit" name="Submit" value="vote" onclick="document.agilent.action=document.agilent.action.replace(\'=result\',\'=vote\');window.open(\'\',\'result_win\',\'width=450,height=250,scrollbars=yes\')"><input type="submit" name="Submit2" value="result" onclick="document.agilent.action=document.agilent.action.replace(\'=vote\',\'=result\');window.open(\'\',\'result_win\',\'width=450,height=250,scrollbars=yes\')"></td></tr></table></form>');

    addvote.asp 

    <%if request.querystring<>"" then%>
    <!--#include file="setup.asp"-->
    <%
    dim rs,sql
    set rs=server.createobject("adodb.recordset")

    select case request.querystring
     case "save"
     on error resume next
     if request("allow_multiple")="yes" then
      conn.execute "insert into question(question,allow_multiple,addtime,total_votes) values('"&request("question")&"',true,now(),0)"
     else
      conn.execute "insert into question(question,addtime,total_votes) values('"&request("question")&"',now(),0)"
     end if
     response.write err.description
     dim follow_id,acount
     sql="select top 1 * from question order by id desc"
     rs.open sql,conn,1,1
     follow_id=rs("id")
     rs.close
     set rs=Nothing
     acount=cint(request("acount"))
     for i=1 to acount
      conn.execute "insert into answer(answer,follow_id,votes) values ('"&request("a"&cstr(i))&"',"&cstr(follow_id)&",0)"
     next
     endconnection
     response.write "<font style='font-size=9pt'>Added new vote successfully!<br><br>This is youe code: <br>Javascript code: <br><textarea cols=52 rows=5><script language=javascript src='http://"&request.servervariables("server_name")&replace(request.servervariables("script_name"),"addvote","vote")&"?id="&cstr(follow_id)&"'></script></textarea><br>HTML code: <br><textarea cols=52 rows=5><a href='http://"&request.servervariables("server_name")&replace(request.servervariables("script_name"),"addvote","default")&"?id="&cstr(follow_id)&"' target=_blank>"&request("question")&"</a></textarea><br>UBB code: <br><textarea cols=52 rows=5>"&request("question")&"</textarea><br><br><tr><td><script language=javascript src='http://"&request.servervariables("server_name")&replace(request.servervariables("script_name"),"addvote","vote")&"?id="&cstr(follow_id)&"'></script>&nbsp;</td></tr></table><br><br>[<a href=default.asp>Retun to Home</a>]</font>"
     case "login"
     sql="select * from admin where user='"&request("username")&"' and pwd='"&request("password")&"'"
     rs.open sql,conn,1,1
     if rs.eof and rs.bof then
      response.write "Wrong user name or password!"
     else
      session("login")=true
      response.redirect request.servervariables("script_name")
     end if
     rs.close
     set rs=nothing
     endconnection
    end select
    else
    %>
    <HTML>
    <HEAD>
    <TITLE>Add vote</TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="Alvin">
    <META NAME="Keywords" CONTENT="voting">
    <META NAME="Description" CONTENT="voting">
    <style type="text/css">
    <!--
    td {  font-size: 9pt}
    body {  font-size: 9pt}
    -->
    </style>
    </HEAD>

    <BODY BGCOLOR="#FFFFFF">
    <%if session("login")<>true then%>
    <form name="form2" method="post" action="<%=request.servervariables("script_name")%>?login">

      <table width="250" border="0" align="center" bgcolor="#FFFFCC">
        <tr>
          <td colspan="2" bgcolor="#FFCC00">
            <div align="center">admin login</div>
          </td>
        </tr>
        <tr>
          <td nowrap>
            <div align="right">User name: </div>
          </td>
          <td nowrap>
            <input type="text" name="username">
             </td>
        </tr>
        <tr>
          <td nowrap>
            <div align="right">Password: </div>
          </td>
          <td nowrap>
            <input type="password" name="password">
             </td>
        </tr>
        <tr>
          <td nowrap> </td>
          <td nowrap>
            <input type="submit" name="Submit4" value="login">
            <input type="reset" name="Submit5" value="cancel">
          </td>
        </tr>
      </table>
    </form>
    <%else%>
    <%if request("question")="" then%>
    <form name="form1" method="post" action="<%=request.servervariables("script_name")%>">

      <table width="88%" border="0" align="center" cellspacing="0" cellpadding="3">
        <tr>
          <td bgcolor="#FFCC00">Step 1: Enter the question</td>
        </tr>
        <tr>
          <td bgcolor="#FFFFCC">Question: 
            <input type="text" name="question" size="48">
            </td>
        </tr>
        <tr>
          <td bgcolor="#FFFFCC">How many selection in total:
            <input type="text" name="acount" size="3" value="15" maxlength="2">
          </td>
        </tr>
        <tr>
          <td bgcolor="#FFFFCC">
            <div align="center">
              <input type="submit" name="Submit" value="next">
              <input type="reset" name="Submit2" value="Cancel">
            </div>
          </td>
        </tr>
      </table>
    </form>
    <%else%>
    <form name="form3" method="post" action="<%=request.servervariables("script_name")%>?save">

      <table width="60%" border="0" align="center" cellspacing="0" cellpadding="3">
        <tr>
          <td bgcolor="#FFCC00">Step 2: Enter the answer</td>
        </tr>
        <tr>
          <td bgcolor="#FFFFCC">Question <b><%=request("question")%></b>
            <input type=hidden name=question value="<%=request("question")%>">
          </td>
        </tr>
        <tr>
          <td bgcolor="#FFFFCC">
            <p><br>
              How many answer in total <input type=hidden name=acount value="<%=request("acount")%>"></p>
            <p>
              <%
    for i=1 to cint(request("acount"))
             response.write  "Answer"&cstr(i)&":<input type=text name=a"&cstr(i)&"><br>"
    next
    %>
            </p>
          </td>
        </tr>
        <tr>
          <td bgcolor="#FFFFCC">
            <input type="checkbox" name="allow_multiple" value="yes">
            Allow multiple choice</td>
        </tr>
        <tr>
          <td bgcolor="#FFFFCC">
            <div align="center">
              <input type="button" name="Submit3" value="&lt;last step" onClick="history.go(-1)">
              <input type="submit" name="Submit" value="Submit">
              <input type="reset" name="Submit2" value="Cancel">
            </div>
          </td>
        </tr>
      </table>
    </form>
    <%
    end if
    end if
    %>
     
    </BODY>
    </HTML>
    <%end if%>

    viewresult.asp

    <!--#include file="setup.asp"-->
    <html>
    <head>
    <title>Result</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <style type="text/css">
    <!--
    td {  font-size: 9pt}
    body {  font-size: 9pt}
    -->
    </style>
    </head>

    <body bgcolor="#FFFFFF">
    <div align="center">

     <table width="93%" border="0">
        <tr bgcolor="#FFCC00">
          <td width="28%">Result</td>
          <td width="60%">Percentage</td>
          <td width="12%">vote</td>
        </tr>
    <%
    sql="select allow_multiple,total_votes from question where id="&request("qid")
    rs.open sql,conn,1,1
    total_votes=rs("total_votes")
    if total_votes=0 then total_votes=1
    rs.close
    sql="select * from answer where follow_id="&request("qid")
    rs.open sql,conn,1,1
    do while not rs.eof
     all_votes=all_votes+rs("votes")
     if all_votes=0 then all_votes=1
     rs.movenext
    loop
    rs.movefirst
    do while not rs.eof
    %>
        <tr nowrap bgcolor="#FFFFCC">
          <td width="28%"><%=rs("answer")%></td>
          <td width="60%"><img src="bar.bmp" name=bar height=12 width=<%=cstr(FormatPercent(rs("votes")*0.68/all_votes,2))%>>
            <%=cstr(FormatPercent(rs("votes")/all_votes,2))%></td>
          <td width="12%"><%=rs("votes")%></td>
        </tr>
    <%
    rs.movenext
    loop
    rs.close
    set rs=nothing
    endconnection
    %>
        <tr nowrap>
          <td width="28%"> </td>
          <td width="60%">
            <div align="right">Total<%=total_votes%>employee vote</div></td>
          <td width="12%">Total<%=all_votes%></td>
        </tr>
      </table>
      <p>[<a href="BLOCKED SCRIPTwindow.close()">Close windows</a>] </p>
    </div>
     

    </body>
    </html>

    result.asp

    <!--#include file="setup.asp"-->
    <html>
    <head>
    <title>Result</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <style type="text/css">
    <!--
    td {  font-size: 9pt}
    body {  font-size: 9pt}
    -->
    </style>
    </head>

    <body bgcolor="#FFFFFF">
    <div align="center">

    <%
    'on error resume next
    dim rs,sql
    set rs=server.createobject("adodb.recordset")
    if request("action")="vote" then
    Filepath = "F:\Inetpub\abc\poll\ssuappraisal.mdb"
    set conn=server.CreateObject("ADODB.Connection")
       conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & FilePath
     sql="select * from votes where follow_id="&request("qid")&" and ip='"&request.servervariables("remote_addr")&"'"
     rs.open sql,conn,1,1
     if rs.bof and rs.eof then
       conn.execute "update votes set [ip]='" & request.servervariables("remote_addr") & "', [follow_id]='" & request("qid") & "'"
       
       ' conn.execute "insert into votes(ip,follow_id) values ('"&request.servervariables("remote_addr")&"',"&request("qid")&")" 
      if request("itype")="chk" then
       for i= 1 to request.form("chk").count
        if isnull(request.form("chk")(i))=false then
         conn.execute "update answer set votes=votes+1 where id="&request.form("chk")(i)
        end if
       next
      else
       if request("rb")<>"" then
        conn.execute "update answer set votes=votes+1 where id="&request("rb")
       end if
      end if
      conn.execute "update question set total_votes=total_votes+1 where id="&request("qid")
      response.write "Your vote is successful, thanks for your vote!"
     else
     response.write "You have voted already!"
     end if
     rs.close
    end if
    %>
      <table width="93%" border="0">
        <tr bgcolor="#FFCC00">
          <td width="28%">Result</td>
          <td width="60%">Percentage</td>
          <td width="12%">Vote</td>
        </tr>
    <%
    sql="select allow_multiple,total_votes from question where id="&request("qid")
    rs.open sql,conn,1,1
    total_votes=rs("total_votes")
    rs.close
    sql="select * from answer where follow_id="&request("qid")
    rs.open sql,conn,1,1
    do while not rs.eof
     all_votes=all_votes+rs("votes")
     rs.movenext
    loop
    if all_votes=0 then all_votes=1
    rs.movefirst
    do while not rs.eof
    %>
        <tr nowrap bgcolor="#FFFFCC">
          <td width="28%"><%=rs("answer")%></td>
          <td width="60%"><img src="bar.bmp" name=bar height=12 width=<%=cstr(FormatPercent(rs("votes")*0.68/all_votes,2))%>>
            <%=cstr(FormatPercent(rs("votes")/all_votes,2))%></td>
          <td width="12%"><%=rs("votes")%></td>
        </tr>
    <%
    rs.movenext
    loop
    rs.close
    set rs=nothing
    endconnection
    if total_votes=0 then all_votes=0
    %>
        <tr nowrap>
          <td width="28%"> </td>
          <td width="60%">
            <div align="right">Total <%=total_votes%>employee vote</div></td>
          <td width="12%">Total<%=all_votes%></td>
        </tr>
        <tr nowrap>
          <td width="28%"> </td>
          <td width="60%">
            <div align="right"> </td>
          <td width="12%">[<a href="BLOCKED SCRIPTwindow.close()">close windows</a>] </td>
        </tr>
      </table>
     
    </div>
    </body>
    </html>
    setup.asp

    <%
    db_name="ssuappraisal.mdb"  'can be path eg: db/news.mdb


    s=split(Request.ServerVariables("PATH_INFO"),"/")
    for i=0 to ubound(s)-1
     path=path+s(i)&"/"
    next
    vote_location="http://"&Request.ServerVariables("SERVER_NAME")&path&"result.asp"
    'result.asp path

    dim conn  
    dim connstr  
    'on error resume next

    connstr = "DBQ=" + server.mappath(db_name) + ";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"      
     set conn=server.createobject("ADODB.CONNECTION")
     if err.number<>0 then
      err.clear
      set conn=nothing
      response.write "database connection error!"
      Response.End
     else
      conn.open connstr
      if err then
       err.clear
       set conn=nothing
       response.write "database connection error!"
       Response.End
      end if
     end if  
     
     sub endConnection()
      conn.close
      set conn=nothing
     end sub

    %>

     

  • 07-20-2009, 11:24 PM In reply to

    Re: [Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query

    Make sure the app pool user and / or anonymous user has permissions to write to the folder hosting the access database.  Access creates a LDB file and when it can't do that, the error you posted comes up.  Bing or Google this error and you'll see tons of articles.

    Steve Schofield
    Windows Server MVP - IIS
    http://weblogs.asp.net/steveschofield


    http://www.IISLogs.com
    Log archival solution
    Install, Configure, Forget
  • 07-21-2009, 1:39 AM In reply to

    Re: [Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query

    Hi,

    I did search from Bing / Google but I can't solve it, I already give full permision to my NT login account but it still has the same problem. I update other Access database got no problem.

    Thanks.

  • 07-21-2009, 3:53 AM In reply to

    Re: [Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query

Page 1 of 1 (4 items)
Microsoft Communities